Click here to load reader

P5utda day2

  • View
    210

  • Download
    0

Embed Size (px)

DESCRIPTION

processing course day2

Text of P5utda day2

  • 1. Processing Workshop 3/17-19 @ Processing WS, by R.ISHIHARA / Kuma Lab.

2. Day 2 - You Code and Your Computer Compute 1 -- 2 print(),println() 3 if 4 for Processing WS, by R.ISHIHARA / Kuma Lab. 3. 1. -- 01 size(400,400); 02 //blackstroke,thick 03 stroke(0); 04 strokeWeight(3); 05 //red 06 fill(255,0,0); 07 rect(0,0,300,300); 08 //green 09 fill(0,100,0); 10 rect(0,300,100,100); 11 //white 12 fill(255); 13 rect(100,300,200,50); 14 rect(100,350,200,50); 15 rect(300,100,50,200); 16 rect(350,100,50,200); 17 //yellow 18 fill(255,255,0); 19 rect(300,0,100,100); 20 //blue 21 fill(0,0,255); 22 rect(300,300,100,100); Processing WS, by R.ISHIHARA / Kuma Lab. 4. 1. -- Processing WS, by R.ISHIHARA / Kuma Lab. 5. 1. -- . processing xpositionX PI 1 floatxPosition=100; 2 //"type" =; Processing WS, by R.ISHIHARA / Kuma Lab. 6. 1. -- 1. int 2. float 3. String 4. boolean / Processing WS, by R.ISHIHARA / Kuma Lab. 7. 2. print(), println() println() 1 intnumber=15; 2 floatdecimal=.55; 3 println(number); 4 println("number="+number); Processing WS, by R.ISHIHARA / Kuma Lab. 8. 2. print(), println() = 01 floatangle=0; 02 floattheta=QUARTER_PI; 03 04 println(sin(angle)); 05 angle=angle+theta; 06 println(sin(angle)); 07 angle=angle+theta; 08 println(sin(angle)); 09 angle=angle+theta; 10 println(sin(angle)); Processing WS, by R.ISHIHARA / Kuma Lab. 9. Processing WS, by R.ISHIHARA / Kuma Lab. 10. 01 size(400,400); 02 03 //blackstroke,thick 04 stroke(0); 05 strokeWeight(5); 06 07 floatscale1=3*width/4; 08 floatscale2=width-scale1; 09 floatscale3=scale2*.5; 10 floatscale4=scale1-scale2; 11 12 //red 13 fill(255,0,0); 14 rect(0,0,scale1,scale1); 15 16 //green 17 fill(0,100,0); 18 rect(0,scale1,scale2,scale2); 19 20 //white 21 fill(255); 22 rect(scale2,scale1,scale4,scale3); 23 rect(scale2,scale1+scale3,scale4,scale3); 24 rect(scale1,scale2,scale3,scale4); 25 rect(scale1+scale3,scale2,scale3,scale4); 26 27 //yellow 28 fill(255,255,0); 29 rect(scale1,0,scale2,scale2); 30 31 //blue 32 fill(0,0,255); 33 rect(scale1,scale1,scale2,scale2); 11. 3. if fillrect Processing WS, by R.ISHIHARA / Kuma Lab. 12. 3. if if(){} 1 size(400,400); 2 floatdimension=100; 3 if(dimension>width*.5){ 4 fill(255,0,0); 5 } 6 else{ 7 fill(0,0,255); 8 } 9 rect(width/4,height/4,width/4,height/4); Processing WS, by R.ISHIHARA / Kuma Lab. 13. 4. for for(;;){} 1 size(400,400); 2 colorMode(RGB,255,255,255,width); 3 for(floatscale=0;scale