RosettaCodeData/Task/Constrained-random-points-on-a-circle/Icon/constrained-random-points-on-a-circle.icon
2023-07-01 13:44:08 -04:00

25 lines
675 B
Text

link graphics
procedure main(A) # points, inside r, outside r in pixels - default to task values
if \A[1] == "help" then stop("Usage: plot #points inside-radius outside-radius")
points := \A[1] | 100
outside := \A[2] | 15
inside := \A[3] | 10
if inside > outside then inside :=: outside
wsize := integer(2.2*outside)
wsize <:= 150
center := wsize/2
WOpen("size="||wsize||","||wsize,"bg=black","fg=white") | stop("Unable to open window")
until(points -:= 1) <= 0 do {
x := ?(2*outside)-outside # random x
y := ?(2*outside)-outside # and y
if (inside <= integer(sqrt(x^2+y^2)) ) <= outside then
DrawPoint(x + center,y + center)
}
WDone()
end