Polyspiral: Difference between revisions
Content added Content deleted
m (→{{header|zkl}}: opps, wrong place) |
(→{{header|Java}}: added zkl) |
||
Line 141: | Line 141: | ||
}); |
}); |
||
} |
} |
||
}</lang> |
|||
=={{header|zkl}}== |
|||
[[File:PolySprial.zkl.gif|250px|thumb|right]] |
|||
If you click on the image, it is animated. |
|||
Uses the PPM class from http://rosettacode.org/wiki/Bitmap/Bresenham%27s_line_algorithm#zkl |
|||
<lang zkl>w,h:=640,640; |
|||
bitmap:=PPM(w,h,0xFF|FF|FF); // White background |
|||
angleIncrement:=(3.0).toRad(); |
|||
while(True){ |
|||
r,angle:=0.0, 0.0; |
|||
ao,len,inc:=w/2, 2.5, angleIncrement+(130.0).toRad(); |
|||
foreach c in (128){ |
|||
s,a:=r + len, angle + inc; |
|||
x,y:=r.toRectangular(angle); |
|||
u,v:=r.toRectangular(a); |
|||
c=c.shiftLeft(21) + c.shiftLeft(10) + c*8; // convert c to a RGB |
|||
bitmap.line(ao+x,ao+y, ao+u,ao+v, c); |
|||
r,angle=s,a; |
|||
} |
|||
bitmap.writeJPGFile("polyspiral.zkl.jpg"); |
|||
bitmap.fill(0xFF|FF|FF); // White background |
|||
angleIncrement=(angleIncrement + 0.05); |
|||
Atomic.sleep(3); |
|||
}</lang> |
}</lang> |