본문 바로가기

Processing

2. Processing 코드 공유





이미 말한대로 김건우 학생이 자바스크립트를 올려 놓았고, 해당 파일을 포함하고 있기에 이전 글 처럼 자바스크립트 형태로 캔버스에 원하는 프로세싱 코드를 포함할 수 있습니다. 하지만 늘 그렇듯 세상은 이미 앞서 나가는 사람들이 있고, 그들을 부지런히 따라가기에도 힘이 든것이 사실이네요.

이번에 소개할 사이트는 이름하여

studio sketchpad(http://sketchpad.cc/)

자신의 프로세싱 코드를 작성해서 협업도 가능하고 공유도 아주 쉽게 할 수 있네요.


/ Pressing Control-R will render this sketch.

int i = 0; 

void setup() {  // this is run once.   
    
    // set the background color
    background(255);
    
    // canvas size (Variable aren't evaluated. Integers only, please.)
    size(300, 300); 
      
    // smooth edges
    smooth();
    
    // limit the number of frames per second
    frameRate(30);
    
    // set the width of the line. 
    strokeWeight(12);

void draw() {  // this is run repeatedly.  

    // set the color
    stroke(random(50), random(255), random(255), 100);
    
    // draw the line
    line(i, 0, random(0, width), height);
    
    // move over a pixel
    if (i < width) {
        i++;
    } else {
        i = 0; 
    }
}

위의 코드를 사이트에 입력후 실행한 화면입니다. 결과는 iframe으로 삽입하게 되어 있는 구조네요.



동일한 코드를 기존의 캔버스에 자바스크립트로 넣으면 다음과 같게 되네요. 어느것이 좋을지는 여러분이 판단하세요.^^



'Processing' 카테고리의 다른 글

1. 프로세싱이란?  (1) 2013.11.14