Constrained random points on a circle: Difference between revisions
Content added Content deleted
m (remove flag for previously unstable feature) |
(Added solution for Action!) |
||
Line 28: | Line 28: | ||
print_circle(10, 15, 100)</lang> |
print_circle(10, 15, 100)</lang> |
||
=={{header|Action!}}== |
|||
<lang Action!>PROC DrawCircle(BYTE rmin,rmax,max,x0,y0) |
|||
BYTE count,limit |
|||
INT x,y,r2,rmin2,rmax2 |
|||
limit=rmax*2+1 |
|||
rmin2=rmin*rmin |
|||
rmax2=rmax*rmax |
|||
count=0 |
|||
WHILE count<max |
|||
DO |
|||
x=Rand(limit) y=Rand(limit) |
|||
x==-rmax y==-rmax |
|||
r2=x*x+y*y |
|||
IF r2>=rmin2 AND r2<=rmax2 THEN |
|||
Plot(x+x0,y+y0) |
|||
count==+1 |
|||
FI |
|||
OD |
|||
RETURN |
|||
PROC Main() |
|||
BYTE CH=$02FC,COLOR0=$02C4 |
|||
Graphics(5+16) |
|||
Color=1 |
|||
COLOR0=$0C |
|||
DrawCircle(10,15,100,40,24) |
|||
DO UNTIL CH#$FF OD |
|||
CH=$FF |
|||
RETURN</lang> |
|||
{{out}} |
|||
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Constrained_random_points_on_a_circle.png Screenshot from Atari 8-bit computer] |
|||
=={{header|Ada}}== |
=={{header|Ada}}== |