*

\ range changed from [0,2pi] to [0,1] for the angle
: 2pi 2 pi * ; : cos 2pi * cos ; : sin 2pi * sin ;
: atan2 atan2 2pi / 1 mod ;
\ memory used
: xo 0 @ ; : xo! 0 ! ; .500 xo!
: yo 1 @ ; : yo! 1 ! ; .500 yo!
: ao 2 @ ; : ao! 2 ! ;
: ro 3 @ ; : ro! 3 ! ; .500 ro!
: strength 4 @ ; 0299 4 !
\ the distance from xo,yo to x,y
: r' ( -- radius ) x 0 @ - 2 ** y 1 @ - 2 ** + .5 ** ;
\ the angle from xo,yo to x,y
: a' ( -- angle ) y 1 @ - x 0 @ - atan2 2 @ - 1 mod ;
\ relative x',y' at origin xo,yo rotating ao
: x' r' a' cos * ;
: y' r' a' sin * ;
: circle ( Xc Yc -- circle ) x' rot - dup * y' rot - dup * + sqrt ro < ;
: 反 0 max 1 min 1 swap - ;
: contour ( f y -- line ) - abs 反 strength ** ;
: axis 0 x' contour y' 0 > * 0 y' contour + 0 0 circle + ;
: between ( n a b -- a<n<b ) push over pop < push > pop * ;
: point ( X Y -- ) >r dup r@ circle swap
\
dup x' contour y' 0 r@ between * swap
r> y' contour swap x' 0 rot between * + + ;
\ R
.50 xo! .50 yo! .10 ao! .02 ro! axis
\ G
.35 xo! .20 yo! .00 ao! axis
\ B
.09 xo! a' .1 < r' .1 contour *
.35 xo! .350 .600 point +
.50 xo! .50 yo! .10 ao! .338 .124 point +

comments powered by Disqus