37 lines
509 B
Text
37 lines
509 B
Text
int n = 18;
|
|
String f1 = "1";
|
|
String f2 = "0";
|
|
String f3;
|
|
|
|
|
|
void setup(){
|
|
size(600,600);
|
|
background(255);
|
|
translate(10, 10);
|
|
createSeries();
|
|
}
|
|
|
|
void createSeries(){
|
|
for(int i=0; i<n; i++){
|
|
f3 = f2+f1;
|
|
f1 = f2;
|
|
f2 = f3;
|
|
}
|
|
drawFractal();
|
|
}
|
|
|
|
void drawFractal(){
|
|
char[] a = f3.toCharArray();
|
|
for(int i=0; i<a.length; i++){
|
|
if(a[i]=='0'){
|
|
if(i%2==0){
|
|
rotate(PI/2);
|
|
}
|
|
else{
|
|
rotate(-PI/2);
|
|
}
|
|
}
|
|
line(0,0,2,0);
|
|
translate(2,0);
|
|
}
|
|
}
|