Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
45
Task/Koch-curve/Processing/koch-curve.processing
Normal file
45
Task/Koch-curve/Processing/koch-curve.processing
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
int l = 300;
|
||||
|
||||
void setup() {
|
||||
size(400, 400);
|
||||
background(0, 0, 255);
|
||||
stroke(255);
|
||||
// draw from center of screen
|
||||
translate(width/2.0, height/2.0);
|
||||
// center curve from lower-left corner of base equilateral triangle
|
||||
translate(-l/2.0, l*sqrt(3)/6.0);
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
kcurve(0, l);
|
||||
rotate(radians(120));
|
||||
translate(-l, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void kcurve(float x1, float x2) {
|
||||
float s = (x2-x1)/3;
|
||||
if (s < 5) {
|
||||
pushMatrix();
|
||||
translate(x1, 0);
|
||||
line(0, 0, s, 0);
|
||||
line(2*s, 0, 3*s, 0);
|
||||
translate(s, 0);
|
||||
rotate(radians(60));
|
||||
line(0, 0, s, 0);
|
||||
translate(s, 0);
|
||||
rotate(radians(-120));
|
||||
line(0, 0, s, 0);
|
||||
popMatrix();
|
||||
return;
|
||||
}
|
||||
pushMatrix();
|
||||
translate(x1, 0);
|
||||
kcurve(0, s);
|
||||
kcurve(2*s, 3*s);
|
||||
translate(s, 0);
|
||||
rotate(radians(60));
|
||||
kcurve(0, s);
|
||||
translate(s, 0);
|
||||
rotate(radians(-120));
|
||||
kcurve(0, s);
|
||||
popMatrix();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue