Yin and yang: Difference between revisions

Content added Content deleted
(Add CLU)
(Added solution for Action!)
Line 218: Line 218:


And here is the output: [https://ibb.co/fDxTXhY Screenshot of NEOGEO displaying two Yin-Yangs]
And here is the output: [https://ibb.co/fDxTXhY Screenshot of NEOGEO displaying two Yin-Yangs]

=={{header|Action!}}==
{{libheader|Action! Tool Kit}}
{{libheader|Action! Real Math}}
<lang Action!>INCLUDE "H6:REALMATH.ACT"
INCLUDE "D2:CIRCLE.ACT" ;from the Action! Tool Kit

PROC YinYang(INT x BYTE y BYTE r)
INT i,a,b,rr,r2,rr2,r5,rr5,y1,y2
REAL tmp1,tmp2

Circle(x,y,r,1)

rr=r*r
r2=r/2 rr2=rr/4
Color=1
FOR i=0 TO r
DO
a=rr-i*i
IntToReal(a,tmp1)
Sqrt(tmp1,tmp2)
a=RealToInt(tmp2)

b=rr2-(i-r2)*(i-r2)
IntToReal(b,tmp1)
Sqrt(tmp1,tmp2)
b=RealToInt(tmp2)

Plot(x+b,y-i) DrawTo(x+a,y-i)
Plot(x-b,y+i) DrawTo(x+a,y+i)
OD

r5=r/5
rr5=rr/25
y1=y-r2 y2=y+r2
FOR i=0 TO r5
DO
a=rr5-i*i
IntToReal(a,tmp1)
Sqrt(tmp1,tmp2)
a=RealToInt(tmp2)

Color=1
Plot(x-a,y1-i) DrawTo(x+a,y1-i)
Plot(x-a,y1+i) DrawTo(x+a,y1+i)

Color=0
Plot(x-a,y2-i) DrawTo(x+a,y2-i)
Plot(x-a,y2+i) DrawTo(x+a,y2+i)
OD
RETURN

PROC Main()
BYTE CH=$02FC,COLOR1=$02C5,COLOR2=$02C6

Graphics(8+16)
MathInit()
COLOR1=$00
COLOR2=$0F

YinYang(180,120,60)
YinYang(100,40,30)

DO UNTIL CH#$FF OD
CH=$FF
RETURN</lang>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Yin_and_yang.png Screenshot from Atari 8-bit computer]


=={{header|Ada}}==
=={{header|Ada}}==