117
edits
(→11/11) |
|||
Line 704: | Line 704: | ||
} | } | ||
popMatrix(); | popMatrix(); | ||
} | |||
=== Andreas Dietrich === | |||
Sketches for the practice homework: | |||
===== First Sketch ===== | |||
[[File:Homework_AD_1.png]] | |||
int dia=50;<br/> | |||
int innerDia=150;<br/> | |||
int steps=30;<br/> | |||
int steps2=30;<br/> | |||
int steps3=30;<br/> | |||
int offset1=0;<br/> | |||
int offset2=10;<br/> | |||
int offset3=20;<br/> | |||
size(900, 600); | |||
for (int k=0;k<3; k++) { | |||
for (int l=0;l<2; l++) { | |||
pushMatrix(); | |||
translate(k*innerDia*2+innerDia, 2*innerDia*l+innerDia); | |||
smooth(); | |||
noStroke(); | |||
fill(255); | |||
beginShape(); | |||
for (int i=0; i<360/steps;i++) { | |||
vertex(sin(radians(i*steps+offset1))*dia, cos(radians(i*steps+offset1))*dia); | |||
vertex(sin(radians(i*steps+steps/2.0+offset1))*innerDia, cos(radians(i*steps+steps/2.0+offset1))*innerDia); | |||
} | |||
endShape(CLOSE); | |||
fill(150); | |||
beginShape(); | |||
for (int i=0; i<360/steps2;i++) { | |||
vertex(sin(radians(i*steps2+offset2))*dia, cos(radians(i*steps2+offset2))*dia); | |||
vertex(sin(radians(i*steps2+steps2/2.0+offset2))*innerDia, cos(radians(i*steps2+steps2/2.0+offset2))*innerDia); | |||
} | |||
endShape(CLOSE); | |||
fill(0); | |||
beginShape(); | |||
for (int i=0; i<360/steps3;i++) { | |||
vertex(sin(radians(i*steps3+offset3))*dia, cos(radians(i*steps3+offset3))*dia); | |||
vertex(sin(radians(i*steps3+steps3/2.0+offset3))*innerDia, cos(radians(i*steps3+steps3/2.0+offset3))*innerDia); | |||
} | |||
endShape(CLOSE); | |||
popMatrix(); | |||
} | |||
} | |||
===== Second Sketch ===== | |||
[[File:Homework_AD_2.png]] | |||
int dia=50;<br/> | |||
int innerDia=150;<br/> | |||
int steps=60;<br/> | |||
float offset1=0;<br/> | |||
float offset2=10;<br/> | |||
float offset3=20;<br/> | |||
float CONST_OFFSET1=0;<br/> | |||
float CONST_OFFSET2=10;<br/> | |||
float CONST_OFFSET3=20;<br/> | |||
float speed1=1;<br/> | |||
float speed2=0.5;<br/> | |||
float speed3=0.7;<br/> | |||
void setup() { | |||
size(900, 600); | |||
smooth(); | |||
noStroke(); | |||
} | |||
void draw() { | |||
background(255); | |||
for (int k=0;k<3; k++) { | |||
for (int l=0;l<2; l++) { | |||
pushMatrix(); | |||
translate(k*innerDia*2+innerDia, 2*innerDia*l+innerDia); | |||
fill(255, 0, 0); | |||
beginShape(); | |||
for (int i=0; i<360/steps;i++) { | |||
vertex(sin(radians(i*steps+offset1))*dia, cos(radians(i*steps+offset1))*dia); | |||
vertex(sin(radians(i*steps+steps/2.0+offset1))*innerDia, cos(radians(i*steps+steps/2.0+offset1))*innerDia); | |||
} | |||
endShape(CLOSE); | |||
fill(0, 255, 0); | |||
beginShape(); | |||
for (int i=0; i<360/steps;i++) { | |||
vertex(sin(radians(i*steps+offset2))*dia, cos(radians(i*steps+offset2))*dia); | |||
vertex(sin(radians(i*steps+steps/2.0+offset2))*innerDia, cos(radians(i*steps+steps/2.0+offset2))*innerDia); | |||
} | |||
endShape(CLOSE); | |||
fill(0, 0, 255); | |||
beginShape(); | |||
for (int i=0; i<360/steps;i++) { | |||
vertex(sin(radians(i*steps+offset3))*dia, cos(radians(i*steps+offset3))*dia); | |||
vertex(sin(radians(i*steps+steps/2.0+offset3))*innerDia, cos(radians(i*steps+steps/2.0+offset3))*innerDia); | |||
} | |||
endShape(CLOSE); | |||
offset1+=speed1; | |||
offset2+=speed2; | |||
offset3+=speed3; | |||
if (offset1> steps+CONST_OFFSET1) { | |||
offset1=CONST_OFFSET1; | |||
} | |||
if (offset2> steps+CONST_OFFSET2) { | |||
offset2=CONST_OFFSET2; | |||
} | |||
if (offset3> steps+CONST_OFFSET3) { | |||
offset3=CONST_OFFSET3; | |||
} | |||
popMatrix(); | |||
} | |||
} | |||
} | |||
===== Third Sketch ===== | |||
[[File:Homework_AD_3.png]] | |||
int dia=50;<br/> | |||
int innerDia=150;<br/> | |||
int steps=30;<br/> | |||
float offset1=0;<br/> | |||
float offset2=10;<br/> | |||
float offset3=20;<br/> | |||
float CONST_OFFSET1=0;<br/> | |||
float CONST_OFFSET2=10;<br/> | |||
float CONST_OFFSET3=20;<br/> | |||
float speed1=1;<br/> | |||
float speed2=0.5;<br/> | |||
float speed3=0.7;<br/> | |||
float scaleVal=0.1;<br/> | |||
float currentScale=1;<br/> | |||
float toScaleVal=1;<br/> | |||
void setup() { | |||
size(900, 600); | |||
smooth(); | |||
frameRate(12); | |||
noStroke(); | |||
} | |||
void draw() { | |||
background(255); | |||
for (int k=0;k<3; k++) { | |||
for (int l=0;l<2; l++) { | |||
pushMatrix(); | |||
translate(k*innerDia*2+innerDia, 2*innerDia*l+innerDia); | |||
if (scaleVal>0) { | |||
if (currentScale>=toScaleVal) { | |||
toScaleVal=random(2.0)-1.0; | |||
if (toScaleVal>currentScale) { | |||
scaleVal=+0.1; | |||
} | |||
else { | |||
scaleVal=-0.1; | |||
} | |||
} | |||
} | |||
if (scaleVal<0) { | |||
if (currentScale<=toScaleVal) { | |||
toScaleVal=random(2.0)-1.0; | |||
if (toScaleVal>currentScale) { | |||
scaleVal=+0.01; | |||
} | |||
else { | |||
scaleVal=-0.01; | |||
} | |||
} | |||
} | |||
currentScale+=scaleVal; | |||
scale(currentScale); | |||
fill(255, 0, 0); | |||
beginShape(); | |||
for (int i=0; i<360/steps;i++) { | |||
vertex(sin(radians(i*steps+offset1))*dia, cos(radians(i*steps+offset1))*dia); | |||
vertex(sin(radians(i*steps+steps/2.0+offset1))*innerDia, cos(radians(i*steps+steps/2.0+offset1))*innerDia); | |||
} | |||
endShape(CLOSE); | |||
fill(0, 255, 0); | |||
beginShape(); | |||
for (int i=0; i<360/steps;i++) { | |||
vertex(sin(radians(i*steps+offset2))*dia, cos(radians(i*steps+offset2))*dia); | |||
vertex(sin(radians(i*steps+steps/2.0+offset2))*innerDia, cos(radians(i*steps+steps/2.0+offset2))*innerDia); | |||
} | |||
endShape(CLOSE); | |||
fill(0, 0, 255); | |||
beginShape(); | |||
for (int i=0; i<360/steps;i++) { | |||
vertex(sin(radians(i*steps+offset3))*dia, cos(radians(i*steps+offset3))*dia); | |||
vertex(sin(radians(i*steps+steps/2.0+offset3))*innerDia, cos(radians(i*steps+steps/2.0+offset3))*innerDia); | |||
} | |||
endShape(CLOSE); | |||
offset1+=speed1; | |||
offset2+=speed2; | |||
offset3+=speed3; | |||
if (offset1> steps+CONST_OFFSET1) { | |||
offset1=CONST_OFFSET1; | |||
} | |||
if (offset2> steps+CONST_OFFSET2) { | |||
offset2=CONST_OFFSET2; | |||
} | |||
if (offset3> steps+CONST_OFFSET3) { | |||
offset3=CONST_OFFSET3; | |||
} | |||
popMatrix(); | |||
} | |||
} | |||
} | } |
edits