124
edits
(Created page with "= Groving Ivy = == Observations == === short description === The pattern of growing ivy is a pretty dense one. The leaves are the smallest elements within that pattern. Looking ...") |
No edit summary |
||
Line 28: | Line 28: | ||
== PROGRAM == | == PROGRAM == | ||
=== sketches === | |||
==== ivy leave ==== | |||
<syntaxhighlight lang="cpp"> | |||
void setup() { | |||
size(500, 500); | |||
background(255); | |||
smooth(); | |||
stroke(55); | |||
strokeWeight(0.25); | |||
frameRate(15); | |||
} | |||
void draw() { | |||
background(0); | |||
for (int i = 0; i < 5; i++) { | |||
pushMatrix(); | |||
for (int j = 0; j < 5; j++) { | |||
float colorFactor = calculateColorFactor(random(1.5, 3.5)); | |||
ivyLeave(colorFactor); | |||
translate(80, 0); | |||
} | |||
popMatrix(); | |||
translate(0, 80); | |||
} | |||
float timeInSeconds = millis()/1000; | |||
if (timeInSeconds % 5 == 0) { | |||
println("five seconds have passed"); | |||
} | |||
} | |||
void ivyLeave(float colorFactor) { | |||
fill(colorFactor*10, 50); | |||
noStroke(); | |||
triangle(50, 120, 100, 40, 150, 120); | |||
pushMatrix(); | |||
rotate(150); | |||
translate(-62, 20); | |||
triangle(15, 130, 40, 70, 65, 130); | |||
popMatrix(); | |||
pushMatrix(); | |||
rotate(-150); | |||
translate(125, -125); | |||
triangle(15, 130, 40, 70, 65, 130); | |||
popMatrix(); | |||
} | |||
float calculateColorFactor(float r) { | |||
float newColor = r*10; | |||
return newColor; | |||
} | |||
</syntaxhighlight> | |||
==== ivy leave 2 ==== | |||
<syntaxhighlight lang="cpp"> | |||
void setup() { | |||
size(500, 500); | |||
background(0); | |||
smooth(); | |||
stroke(55); | |||
strokeWeight(0.25); | |||
frameRate(15); | |||
} | |||
void draw() { | |||
//background(0); | |||
//fill(0,50); | |||
//rect(0,0,width,height); | |||
if (mousePressed == true) { | |||
variableIvyLeave(); | |||
} | |||
} | |||
void ivyLeave() { | |||
//noStroke(); | |||
fill(150, 50); | |||
pushMatrix(); | |||
translate(-50, -120); | |||
triangle(50, 120, 100, 40, 150, 120); | |||
pushMatrix(); | |||
rotate(150); | |||
translate(-62, 20); | |||
triangle(15, 130, 40, 70, 65, 130); | |||
popMatrix(); | |||
pushMatrix(); | |||
rotate(-150); | |||
translate(125, -125); | |||
triangle(15, 130, 40, 70, 65, 130); | |||
popMatrix(); | |||
popMatrix(); | |||
} | |||
void variableIvyLeave() { | |||
pushMatrix(); | |||
translate(mouseX, mouseY); | |||
ivyLeave(); | |||
popMatrix(); | |||
} | |||
</syntaxhighlight> | |||
==== ivy leave 3 ==== | |||
<syntaxhighlight lang="cpp"> | |||
float x = 0; | |||
float y = 0; | |||
float speedX; | |||
float speedY; | |||
float velocityX = 1.0; | |||
float velocityY = 1.0; | |||
//-------------------------- | |||
void setup(){ | |||
size(500,500); | |||
background(0); | |||
smooth(); | |||
frameRate(15); | |||
} | |||
void draw(){ | |||
background(0); | |||
speedX = random(-3, 5); | |||
speedY = random(-5, 5); | |||
variableIvyLeave(x,y); | |||
float timeInSeconds = millis()/1000; | |||
if (timeInSeconds % 1 == 0) { | |||
variableIvyLeave(x,y); | |||
} | |||
if ((x > width) || (x < 0)) { | |||
speedX = abs(speedX); | |||
velocityX = -velocityX; | |||
} | |||
if ((y > height) || (y < 0)) { | |||
speedY = abs(speedY); | |||
velocityY = -velocityY; | |||
} | |||
x += speedX * velocityX; | |||
y += speedY * velocityY; | |||
} | |||
//--------------------------------------- | |||
void ivyLeave(){ | |||
stroke(55); | |||
strokeWeight(0.25); fill(250,60); | |||
//triangle large | |||
triangle(50,120, 100,40, 150,120); | |||
//triangle small left | |||
pushMatrix(); | |||
rotate(150); | |||
translate(-62,20); | |||
triangle(15,130, 40,70, 65,130); | |||
popMatrix(); | |||
//triangle small right | |||
pushMatrix(); | |||
rotate(-150); | |||
translate(125,-125); | |||
triangle(15,130, 40,70, 65,130); | |||
popMatrix(); | |||
} | |||
void variableIvyLeave(float x, float y){ | |||
pushMatrix(); | |||
translate(x,y); | |||
x += random(1,9); | |||
y += random(1,11); | |||
ivyLeave(); | |||
popMatrix(); | |||
} | |||
</syntaxhighlight> | |||
==== ivy leave 4 ==== | |||
[[File:Processing_einfuehrung_julia_ivy4.zip|Download SketchFolder]] | |||
=== final version === | |||
[[File:Processing_einfuehrung_julia_all.zip|Download SketchFolder]] | [[File:Processing_einfuehrung_julia_all.zip|Download SketchFolder]] | ||
edits