Koch curve: Difference between revisions
Content added Content deleted
(Added XPL0 example.) |
|||
Line 2,375: | Line 2,375: | ||
static draw(dt) {} |
static draw(dt) {} |
||
}</lang> |
}</lang> |
||
=={{header|XPL0}}== |
|||
<lang XPL0>real PosX, PosY, Angle; |
|||
proc DrawSide(Depth, Dist); \Draw side as 4 segments |
|||
int Depth; real Dist; |
|||
int I; real Dir; |
|||
def Deg2Rad = 3.14159265358979323846/180.; |
|||
[Dir:= [0., -60., 120., -60.]; |
|||
for I:= 0 to 3 do |
|||
[Angle:= Angle + Dir(I); |
|||
if Depth < 4 then DrawSide(Depth+1, Dist/3.) |
|||
else [PosX:= PosX + Dist*Cos(Angle*Deg2Rad); |
|||
PosY:= PosY + Dist*Sin(Angle*Deg2Rad); |
|||
Line(fix(PosX), fix(PosY), $F \BrWhite\); |
|||
]; |
|||
]; |
|||
]; |
|||
int Side; |
|||
[SetVid($107); \set 1280x1024x8 VESA graphic display |
|||
PosX:= float(1280/2); PosY:= 0.; |
|||
Move(fix(PosX), fix(PosY)); \set start of Line |
|||
Angle:= 60.; \heading = 60 degrees |
|||
for Side:= 1 to 3 do \sides of triangle |
|||
[DrawSide(0, 290.); |
|||
Angle:= Angle + 120.; |
|||
]; |
|||
]</lang> |
|||
{{out}} |
|||
<pre> |
|||
Essentially the same as the C++ image. |
|||
</pre> |
|||
=={{header|zkl}}== |
=={{header|zkl}}== |