Post by dxforthOne for the mathematicians...
.. and the 4tH version. This one fills it up as well. Nice code, easy to port:
\ This version translated to DX-Forth
\ FORTH-F.EXE - INCLUDE WEED BYE
\ -----------------------------------------------
\ Originally programmed in XPL0 by ...
\ http://www.idcomm.com/personal/lorenblaney/
\ Weed.xpl 15-Jan-2009
\ Plots the "Weed" function
[PRAGMA] usestackflood
include lib/fp3.4th \ for floating point
include lib/fsinfcos.4th \ for FSIN
include lib/graphics.4th \ for graphics support
include lib/gflood.4th \ for FLOOD
include 4pp/lib/float.4pp \ since we're using the preprocessor..
f% 100 fconstant S \ size of plotted image (scale factor)
f% 32000 fconstant N \ number of points plotted
pi fdup f+ fconstant 2Pi
0 value X \ graphic coordinates (pixels)
0 value Y
: Main ( -- )
640 pic_width ! 480 pic_height ! \ set canvas size
color_image 255 whiteout black \ paint black on white
." WAIT! - it will get there.." cr \ set 640x480 graphics with 16 colors
f% 0 ( Angle) \ for A:= 0 to Pi2 do...
begin
fdup ( A) fsin f% 1 f+
fover ( A) f% 8 f* fcos f% 0.9e f* f% 1 f+ f*
fover ( A) f% 24 f* fcos f% 0.1e f* f% 1 f+ f*
fover ( A) f% 200 f* fcos f% 0.05e f* f% 0.9e f+ f* ( Distance)
fover ( A) fcos fover ( D) f* S f* f>s to X \ polar to rect
fover ( A) fsin f* S f* f>s to Y
320 X + 400 Y - swap set_pixel
( A) 2Pi N f/ f+ fdup 2Pi f< 0=
until ( A) fdrop
;
Main
green 200 320 flood
s" weed.ppm" save_image \ save the image