RosettaCodeData/Task/Constrained-random-points-on-a-circle/EchoLisp/constrained-random-points-on-a-circle.echolisp
2016-12-05 23:44:36 +01:00

16 lines
459 B
Text

(lib 'math)
(lib 'plot)
(define (points (n 100) (radius 10) (rmin 10) (rmax 15) (x) (y))
(plot-clear)
(plot-x-minmax (- rmax))
(plot-y-minmax( - rmax))
(for [(i n)]
(set! x (round (* (random -1) rmax)))
(set! y (round (* (random -1) rmax)))
#:when (in-interval? (pythagore x y) rmin rmax)
;; add a little bit of randomness : dots color and radius
(plot-fill-color (hsv->rgb (random) 0.9 0.9))
(plot-circle x y (random radius)))
(plot-edit))