Peano curve: Difference between revisions
Content deleted Content added
→Simple Turtle Graphics: $width |
Added Processing implementation |
||
Line 1,111: | Line 1,111: | ||
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span> |
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span> |
||
<!--</lang>--> |
<!--</lang>--> |
||
=={{header|Processing}}== |
|||
{{trans|C}} |
|||
<lang java> |
|||
//Abhishek Ghosh, 28th June 2022 |
|||
void Peano(int x, int y, int lg, int i1, int i2) { |
|||
if (lg == 1) { |
|||
ellipse(x,y,1,1); |
|||
return; |
|||
} |
|||
lg = lg/3; |
|||
Peano(x+(2*i1*lg), y+(2*i1*lg), lg, i1, i2); |
|||
Peano(x+((i1-i2+1)*lg), y+((i1+i2)*lg), lg, i1, 1-i2); |
|||
Peano(x+lg, y+lg, lg, i1, 1-i2); |
|||
Peano(x+((i1+i2)*lg), y+((i1-i2+1)*lg), lg, 1-i1, 1-i2); |
|||
Peano(x+(2*i2*lg), y+(2*(1-i2)*lg), lg, i1, i2); |
|||
Peano(x+((1+i2-i1)*lg), y+((2-i1-i2)*lg), lg, i1, i2); |
|||
Peano(x+(2*(1-i1)*lg), y+(2*(1-i1)*lg), lg, i1, i2); |
|||
Peano(x+((2-i1-i2)*lg), y+((1+i2-i1)*lg), lg, 1-i1, i2); |
|||
Peano(x+(2*(1-i2)*lg), y+(2*i2*lg), lg, 1-i1, i2); |
|||
} |
|||
void setup(){ |
|||
size(1000,1000); |
|||
Peano(0, 0, 1000, 0, 0); |
|||
} |
|||
</lang> |
|||
=={{header|Prolog}}== |
=={{header|Prolog}}== |