#5. Processing -Variations

2023. 4. 25. 14:26Less Code with ChatGPT/Processing

 

 

Code>>

//Set up drawing function
void setup() {
 size(1000, 700, P3D); 
 background(200,0,0); 
 lights();
 
}

//Draw loop
void draw(){ 
 stroke(0);//중심큐브
 fill(227,206,240);
 translate(width/2, height/2, 0);
 rotateX(frameCount * 0.02);
 rotateY(frameCount * 0.02);
 box(200);
 
 stroke(0);//움직이는 100 사이즈 큐브
 fill(100,200,255);
 translate(width/10, height/10, 10);
 rotateX(frameCount * 0.01);
 rotateY(frameCount * 0.02);
 box(100);
 
 noFill();//움직이는 구형
 stroke(0);
 pushMatrix();
 translate(360,height*0.5,360);
 sphere(150);
 popMatrix();
 
 }

 

Run Code>>

https://youtu.be/7zT8IQUXAkw

 

 

 

Variation Code>>
//Set up drawing function
void setup() {
 size(1000, 700, P3D); 
 background(200,0,0); 
 lights();
 }


void draw() {
  if (mousePressed) {
     
 stroke(0);//중심큐브
 fill(227,206,240);
 translate(width/2, height/2, 0);
 rotateX(frameCount * 0.02);
 rotateY(frameCount * 0.02);
 box(200);
 
 stroke(0);//움직이는 100 사이즈 큐브
 fill(100,200,255);
 translate(width/10, height/10, 10);
 rotateX(frameCount * 0.01);
 rotateY(frameCount * 0.02);
 box(100);
 
 noFill();//움직이는 구형
 stroke(0);
 pushMatrix();
 translate(360,height*0.5,360);
 sphere(150);
 popMatrix();
  }
 }


 

Run Code>>

마우스 클릭에 따라 그림이 작동하게 할 수 있다.

프로세싱에서 실행해보기