Yin and yang: Difference between revisions

Content added Content deleted
m (→‎{{header|Phix}}: syntax coloured, added online link)
m (syntax highlighting fixup automation)
Line 13: Line 13:
{{trans|Python}}
{{trans|Python}}


<lang 11l>F yinyang(n = 3)
<syntaxhighlight lang="11l">F yinyang(n = 3)
V radii = [1, 3, 6].map(i -> i * @n)
V radii = [1, 3, 6].map(i -> i * @n)
V ranges = radii.map(r -> Array(-r .. r))
V ranges = radii.map(r -> Array(-r .. r))
Line 33: Line 33:


print(yinyang(2))
print(yinyang(2))
print(yinyang(1))</lang>
print(yinyang(1))</syntaxhighlight>


{{out}}
{{out}}
Line 87: Line 87:
</pre>
</pre>
The code:
The code:
<lang 68000devpac> pushall
<syntaxhighlight lang="68000devpac"> pushall
MOVE.W #1,D0
MOVE.W #1,D0
;base sprite number, needed by NEOGEO hardware
;base sprite number, needed by NEOGEO hardware
Line 215: Line 215:
DC.W $0100,$0100,$0100,$0100,$0100,$0100,$0100,$0100
DC.W $0100,$0100,$0100,$0100,$0100,$0100,$0100,$0100
DC.W $0100,$0100,$0100,$0100,$0100,$0100,$0100,$0100
DC.W $0100,$0100,$0100,$0100,$0100,$0100,$0100,$0100
DC.W $0100,$0100,$0100,$0100,$0100,$0100,$0100,$0100</lang>
DC.W $0100,$0100,$0100,$0100,$0100,$0100,$0100,$0100</syntaxhighlight>


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]
Line 222: Line 222:
{{libheader|Action! Tool Kit}}
{{libheader|Action! Tool Kit}}
{{libheader|Action! Real Math}}
{{libheader|Action! Real Math}}
<lang Action!>INCLUDE "H6:REALMATH.ACT"
<syntaxhighlight lang="action!">INCLUDE "H6:REALMATH.ACT"
INCLUDE "D2:CIRCLE.ACT" ;from the Action! Tool Kit
INCLUDE "D2:CIRCLE.ACT" ;from the Action! Tool Kit


Line 283: Line 283:
DO UNTIL CH#$FF OD
DO UNTIL CH#$FF OD
CH=$FF
CH=$FF
RETURN</lang>
RETURN</syntaxhighlight>
{{out}}
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Yin_and_yang.png Screenshot from Atari 8-bit computer]
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Yin_and_yang.png Screenshot from Atari 8-bit computer]
Line 291: Line 291:
Uses the Cairo component of GtkAda to create and save as png
Uses the Cairo component of GtkAda to create and save as png
[[file:YinYangAda.png|right]]
[[file:YinYangAda.png|right]]
<lang Ada>with Glib; use Glib;
<syntaxhighlight lang="ada">with Glib; use Glib;
with Cairo; use Cairo;
with Cairo; use Cairo;
with Cairo.Png; use Cairo.Png;
with Cairo.Png; use Cairo.Png;
Line 322: Line 322:
Status := Write_To_Png (Surface, "YinYangAda.png");
Status := Write_To_Png (Surface, "YinYangAda.png");
pragma Assert (Status = Cairo_Status_Success);
pragma Assert (Status = Cairo_Status_Success);
end YinYang;</lang>
end YinYang;</syntaxhighlight>


=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==
Line 328: Line 328:
{{works with|ALGOL 68G|Any - tested with release [http://sourceforge.net/projects/algol68/files/algol68g/algol68g-1.18.0/algol68g-1.18.0-9h.tiny.el5.centos.fc11.i386.rpm/download 1.18.0-9h.tiny].}}
{{works with|ALGOL 68G|Any - tested with release [http://sourceforge.net/projects/algol68/files/algol68g/algol68g-1.18.0/algol68g-1.18.0-9h.tiny.el5.centos.fc11.i386.rpm/download 1.18.0-9h.tiny].}}
{{wont work with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download 1.8-8d] - due use of Currying.}}
{{wont work with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download 1.8-8d] - due use of Currying.}}
<lang algol68>INT scale x=2, scale y=1;
<syntaxhighlight lang="algol68">INT scale x=2, scale y=1;
CHAR black="#", white=".", clear=" ";
CHAR black="#", white=".", clear=" ";


Line 365: Line 365:
print yin yang(17);
print yin yang(17);
print yin yang(8)
print yin yang(8)
)</lang>
)</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 423: Line 423:
=={{header|ARM Assembly}}==
=={{header|ARM Assembly}}==
{{works with|as|Raspberry Pi}}
{{works with|as|Raspberry Pi}}
<syntaxhighlight lang="arm assembly">
<lang ARM Assembly>
/* ARM assembly Raspberry PI */
/* ARM assembly Raspberry PI */
/* program yingyang.s */
/* program yingyang.s */
Line 620: Line 620:
.include "../affichage.inc"
.include "../affichage.inc"


</syntaxhighlight>
</lang>
{{Output}}
{{Output}}
<pre>
<pre>
Line 649: Line 649:
=={{header|Asymptote}}==
=={{header|Asymptote}}==
[[File:Yinyang-asymptote.svg|thumb|The resulting EPS, converted to SVG]]
[[File:Yinyang-asymptote.svg|thumb|The resulting EPS, converted to SVG]]
<lang asymptote>unitsize(1 inch);
<syntaxhighlight lang="asymptote">unitsize(1 inch);


fill(scale(6)*unitsquare, invisible);
fill(scale(6)*unitsquare, invisible);
Line 666: Line 666:


add(yinyang((1 + 1/4, 4 + 3/4), 1));
add(yinyang((1 + 1/4, 4 + 3/4), 1));
add(yinyang((3 + 3/4, 2 + 1/4), 2));</lang>
add(yinyang((3 + 3/4, 2 + 1/4), 2));</syntaxhighlight>


=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==
[[file:yin-yang-ahk.png|right]]
[[file:yin-yang-ahk.png|right]]
Requires the GDI+ Standard Library by tic: http://www.autohotkey.com/forum/viewtopic.php?t=32238
Requires the GDI+ Standard Library by tic: http://www.autohotkey.com/forum/viewtopic.php?t=32238
<lang AHK>Yin_and_Yang(50, 50, A_ScriptDir "\YinYang1.png")
<syntaxhighlight lang="ahk">Yin_and_Yang(50, 50, A_ScriptDir "\YinYang1.png")
Yin_and_Yang(300, 300,A_ScriptDir "\YinYang2.png")
Yin_and_Yang(300, 300,A_ScriptDir "\YinYang2.png")


Line 707: Line 707:
gdip_Shutdown(pToken)
gdip_Shutdown(pToken)
return r
return r
}</lang>
}</syntaxhighlight>


=={{header|AWK}}==
=={{header|AWK}}==
<syntaxhighlight lang="awk">
<lang AWK>
# syntax: GAWK -f YIN_AND_YANG.AWK
# syntax: GAWK -f YIN_AND_YANG.AWK
# converted from PHL
# converted from PHL
Line 763: Line 763:
return in_circle(0,0-radius/2,radius/6,x,y)
return in_circle(0,0-radius/2,radius/6,x,y)
}
}
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 822: Line 822:
==={{header|AmigaBASIC}}===
==={{header|AmigaBASIC}}===


<lang amigabasic>pi=3.141592
<syntaxhighlight lang="amigabasic">pi=3.141592
s=.5
s=.5


Line 843: Line 843:
PSET (xp,yp)
PSET (xp,yp)
PAINT (xp+size/4,yp)
PAINT (xp+size/4,yp)
RETURN</lang>
RETURN</syntaxhighlight>


==={{header|Applesoft BASIC}}===
==={{header|Applesoft BASIC}}===
<lang ApplesoftBasic>0 GOTO 6
<syntaxhighlight lang="applesoftbasic">0 GOTO 6
1Y=R:D=1-R:X=0:FORC=0TO1STEP0:M=D>=0:Y=Y-M:D=D-Y*2*M:D=D+X*2+3:HPLOTXC-X,YC+YTOXC+X,YC+Y:HPLOTXC-Y,YC+XTOXC+Y,YC+X:HPLOTXC-X,YC-YTOXC+X,YC-Y:HPLOTXC-Y,YC-XTOXC+Y,YC-X:X=X+1:C=X>=Y:NEXTC:RETURN
1Y=R:D=1-R:X=0:FORC=0TO1STEP0:M=D>=0:Y=Y-M:D=D-Y*2*M:D=D+X*2+3:HPLOTXC-X,YC+YTOXC+X,YC+Y:HPLOTXC-Y,YC+XTOXC+Y,YC+X:HPLOTXC-X,YC-YTOXC+X,YC-Y:HPLOTXC-Y,YC-XTOXC+Y,YC-X:X=X+1:C=X>=Y:NEXTC:RETURN
2Y=R:D=1-R:X=0:FORC=0TO1STEP0:M=D>=0:Y=Y-M:D=D-Y*2*M:D=D+X*2+3:HPLOTXC-X,YC+Y:HPLOTXC+X,YC+Y:HPLOTXC-Y,YC+X:HPLOTXC+Y,YC+X:HPLOTXC-X,YC-Y:HPLOTXC+X,YC-Y:HPLOTXC-Y,YC-X:HPLOTXC+Y,YC-X:X=X+1:C=X>=Y:NEXTC:RETURN
2Y=R:D=1-R:X=0:FORC=0TO1STEP0:M=D>=0:Y=Y-M:D=D-Y*2*M:D=D+X*2+3:HPLOTXC-X,YC+Y:HPLOTXC+X,YC+Y:HPLOTXC-Y,YC+X:HPLOTXC+Y,YC+X:HPLOTXC-X,YC-Y:HPLOTXC+X,YC-Y:HPLOTXC-Y,YC-X:HPLOTXC+Y,YC-X:X=X+1:C=X>=Y:NEXTC:RETURN
Line 865: Line 865:
170 YC = YP + S / 2 : GOSUB 1FILLCIRCLE
170 YC = YP + S / 2 : GOSUB 1FILLCIRCLE
180 HCOLOR = 0 : YC = YP : R = S : GOSUB 2CIRCLE
180 HCOLOR = 0 : YC = YP : R = S : GOSUB 2CIRCLE
190 RETURN</lang>
190 RETURN</syntaxhighlight>


==={{header|BASIC256}}===
==={{header|BASIC256}}===
<syntaxhighlight lang="basic256">
<lang BASIC256>
graphsize 800, 600
graphsize 800, 600
clg
clg
Line 886: Line 886:
call Taijitu(500, 300, 138)
call Taijitu(500, 300, 138)
end
end
</syntaxhighlight>
</lang>


==={{header|BBC BASIC}}===
==={{header|BBC BASIC}}===
[[File:Yinyangbbc.gif|right]]
[[File:Yinyangbbc.gif|right]]
<lang bbcbasic> PROCyinyang(200, 200, 100)
<syntaxhighlight lang="bbcbasic"> PROCyinyang(200, 200, 100)
PROCyinyang(700, 400, 300)
PROCyinyang(700, 400, 300)
END
END
Line 905: Line 905:
CIRCLE FILL xpos%, ypos%+size%/2, size%/6+2
CIRCLE FILL xpos%, ypos%+size%/2, size%/6+2
CIRCLE xpos%, ypos%, size%
CIRCLE xpos%, ypos%, size%
ENDPROC</lang>
ENDPROC</syntaxhighlight>


==={{header|Commodore BASIC}}===
==={{header|Commodore BASIC}}===
Line 913: Line 913:
On a VIC-20 with the SuperExpander cartridge:
On a VIC-20 with the SuperExpander cartridge:


<lang basic>0 REM VIC-20 WITH SUPEREXPANDER
<syntaxhighlight lang="basic">0 REM VIC-20 WITH SUPEREXPANDER
10 GRAPHIC 2
10 GRAPHIC 2
20 COLOR 0,1,1,1
20 COLOR 0,1,1,1
Line 929: Line 929:
160 PAINT 1,X-XR/2,Y
160 PAINT 1,X-XR/2,Y
170 RETURN
170 RETURN
</syntaxhighlight>
</lang>


{{works with|Simons' BASIC}}
{{works with|Simons' BASIC}}


<lang basic>0 REM C64 WITH SIMONS' BASIC
<syntaxhighlight lang="basic">0 REM C64 WITH SIMONS' BASIC
10 COLOUR 0,0
10 COLOUR 0,0
20 HIRES 1,0
20 HIRES 1,0
Line 948: Line 948:
160 PAINT X-XR/2,Y,1
160 PAINT X-XR/2,Y,1
170 RETURN
170 RETURN
</syntaxhighlight>
</lang>


{{works with|Commodore BASIC|3.5,7.0}}
{{works with|Commodore BASIC|3.5,7.0}}
Using the built-in graphics statements available in BASIC 3.5 on the Commodore TED computers (C-16, Plus/4) or BASIC 7.0 on the C-128:
Using the built-in graphics statements available in BASIC 3.5 on the Commodore TED computers (C-16, Plus/4) or BASIC 7.0 on the C-128:


<lang basic>0 REM BASIC 3.5,7.0
<syntaxhighlight lang="basic">0 REM BASIC 3.5,7.0
10 COLOR 0,1:COLOR 1,2:COLOR 4,1
10 COLOR 0,1:COLOR 1,2:COLOR 4,1
20 GRAPHIC 1,1
20 GRAPHIC 1,1
Line 968: Line 968:
160 PAINT 1,X-XR/2,Y
160 PAINT 1,X-XR/2,Y
170 RETURN
170 RETURN
</syntaxhighlight>
</lang>


Images of the results can be seen [https://imgur.com/a/GCekCvC here].
Images of the results can be seen [https://imgur.com/a/GCekCvC here].


==={{header|FreeBASIC}}===
==={{header|FreeBASIC}}===
<lang freebasic>
<syntaxhighlight lang="freebasic">
Screen 19
Screen 19
Color ,7
Color ,7
Line 991: Line 991:
Taijitu(500, 300, 138)
Taijitu(500, 300, 138)
End
End
</syntaxhighlight>
</lang>


==={{header|Gambas}}===
==={{header|Gambas}}===
<lang gambas>Public Sub Form_Open()
<syntaxhighlight lang="gambas">Public Sub Form_Open()
Dim hPictureBox As PictureBox
Dim hPictureBox As PictureBox
Dim siCount As Short
Dim siCount As Short
Line 1,016: Line 1,016:
Next
Next


End</lang>
End</syntaxhighlight>


'''[http://www.cogier.com/gambas/Yin%20and%20yang_270.png Click here to view image]'''
'''[http://www.cogier.com/gambas/Yin%20and%20yang_270.png Click here to view image]'''


==={{header|IS-BASIC}}===
==={{header|IS-BASIC}}===
<lang IS-BASIC>100 PROGRAM "YinYang.bas"
<syntaxhighlight lang="is-basic">100 PROGRAM "YinYang.bas"
110 GRAPHICS HIRES 2
110 GRAPHICS HIRES 2
120 SET PALETTE WHITE,BLACK
120 SET PALETTE WHITE,BLACK
Line 1,033: Line 1,033:
200 SET INK 0:PLOT X,Y+R/2,ELLIPSE R/2,R/2,
200 SET INK 0:PLOT X,Y+R/2,ELLIPSE R/2,R/2,
210 SET INK 1:PLOT X,Y,ELLIPSE R,R,
210 SET INK 1:PLOT X,Y,ELLIPSE R,R,
220 END DEF</lang>
220 END DEF</syntaxhighlight>


==={{header|Liberty BASIC}}===
==={{header|Liberty BASIC}}===
[[File:YinYangLB.gif||200px|thumb|right|Liberty BASIC Graphic Output]]
[[File:YinYangLB.gif||200px|thumb|right|Liberty BASIC Graphic Output]]
<lang lb> WindowWidth =410
<syntaxhighlight lang="lb"> WindowWidth =410
WindowHeight =440
WindowHeight =440


Line 1,082: Line 1,082:
[quit]
[quit]
close #w
close #w
end</lang>
end</syntaxhighlight>


==={{header|Locomotive Basic}}===
==={{header|Locomotive Basic}}===


<lang locobasic>10 mode 2:deg:defint a-z:ink 0,26:ink 1,0:border 26
<syntaxhighlight lang="locobasic">10 mode 2:deg:defint a-z:ink 0,26:ink 1,0:border 26
20 xp=320:yp=200:size=150:gosub 100
20 xp=320:yp=200:size=150:gosub 100
30 xp=550:yp=350:size=40:gosub 100
30 xp=550:yp=350:size=40:gosub 100
Line 1,109: Line 1,109:
2030 draw cx+cr*sin(i),cy+cr*cos(i)
2030 draw cx+cr*sin(i),cy+cr*cos(i)
2040 next
2040 next
2050 return</lang>
2050 return</syntaxhighlight>


==={{header|PureBasic}}===
==={{header|PureBasic}}===
[[File:Yin And yang.png|300px]]
[[File:Yin And yang.png|300px]]
<lang PureBasic>Procedure Yin_And_Yang(x, y, radius)
<syntaxhighlight lang="purebasic">Procedure Yin_And_Yang(x, y, radius)
DrawingMode(#PB_2DDrawing_Outlined)
DrawingMode(#PB_2DDrawing_Outlined)
Circle(x, y, 2 * radius, #Black) ;outer circle
Circle(x, y, 2 * radius, #Black) ;outer circle
Line 1,134: Line 1,134:
path$ = SaveFileRequester("Save image", "Yin And yang.png", "*.png", 0)
path$ = SaveFileRequester("Save image", "Yin And yang.png", "*.png", 0)
If path$ <> "": SaveImage(0, path$, #PB_ImagePlugin_PNG, 0, 2): EndIf
If path$ <> "": SaveImage(0, path$, #PB_ImagePlugin_PNG, 0, 2): EndIf
EndIf</lang>
EndIf</syntaxhighlight>


==={{header|uBasic/4tH}}===
==={{header|uBasic/4tH}}===
<lang>Proc _YinYang (18)
<syntaxhighlight lang="text">Proc _YinYang (18)
End
End


Line 1,167: Line 1,167:
If FUNC(_Circle (a@, b@, c@ / 2, c@ / 2)) Then Return (Ord ("#"))
If FUNC(_Circle (a@, b@, c@ / 2, c@ / 2)) Then Return (Ord ("#"))
If FUNC(_Circle (a@, b@, 0, c@)) Then Return (Iif (a@ < 0, Ord ("."), Ord ("#")))
If FUNC(_Circle (a@, b@, 0, c@)) Then Return (Iif (a@ < 0, Ord ("."), Ord ("#")))
Return (Ord (" "))</lang>
Return (Ord (" "))</syntaxhighlight>
==={{header|VBA}}===
==={{header|VBA}}===
<lang vb>Private Sub yinyang(Top As Integer, Left As Integer, Size As Integer)
<syntaxhighlight lang="vb">Private Sub yinyang(Top As Integer, Left As Integer, Size As Integer)
ActiveSheet.Shapes.AddShape(msoShapeChord, Top, Left, Size, Size).Select
ActiveSheet.Shapes.AddShape(msoShapeChord, Top, Left, Size, Size).Select
With Selection.ShapeRange
With Selection.ShapeRange
Line 1,209: Line 1,209:
yinyang 200, 100, 100
yinyang 200, 100, 100
yinyang 275, 175, 25
yinyang 275, 175, 25
End Sub</lang>
End Sub</syntaxhighlight>


==={{header|Visual Basic .NET}}===
==={{header|Visual Basic .NET}}===
Line 1,218: Line 1,218:
Shows a form with the symbols drawn on it if no command line arguments are given; otherwise, the first and only argument is an integer representing the width and height of the PNG image to generate. The raw data of the generated image is written to the console (redirect to a file to view).
Shows a form with the symbols drawn on it if no command line arguments are given; otherwise, the first and only argument is an integer representing the width and height of the PNG image to generate. The raw data of the generated image is written to the console (redirect to a file to view).


<lang vbnet>Imports System.Drawing
<syntaxhighlight lang="vbnet">Imports System.Drawing
Imports System.Windows.Forms
Imports System.Windows.Forms


Line 1,304: Line 1,304:
End Sub
End Sub
End Class
End Class
End Module</lang>
End Module</syntaxhighlight>


====SVG====
====SVG====
Line 1,311: Line 1,311:
Uses minimal string literals by favoring proper use of the .NET <code>System.Linq.Xml</code> classes (and VB.NET's XML literals, of course ;).
Uses minimal string literals by favoring proper use of the .NET <code>System.Linq.Xml</code> classes (and VB.NET's XML literals, of course ;).


<lang vbnet>Imports System.IO
<syntaxhighlight lang="vbnet">Imports System.IO


' Yep, VB.NET can import XML namespaces. All literals have xmlns changed, while xmlns:xlink is only
' Yep, VB.NET can import XML namespaces. All literals have xmlns changed, while xmlns:xlink is only
Line 1,351: Line 1,351:
End Using
End Using
End Sub
End Sub
End Module</lang>
End Module</syntaxhighlight>


{{out}}
{{out}}
<lang xml><?xml version="1.0" encoding="utf-8" standalone="no"?>
<syntaxhighlight lang="xml"><?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" width="30" height="30" xmlns="http://www.w3.org/2000/svg">
<svg version="1.1" width="30" height="30" xmlns="http://www.w3.org/2000/svg">
Line 1,367: Line 1,367:
<use xlink:href="#y" transform="translate(20,20) scale(0.05)" xmlns:xlink="http://www.w3.org/1999/xlink" />
<use xlink:href="#y" transform="translate(20,20) scale(0.05)" xmlns:xlink="http://www.w3.org/1999/xlink" />
<use xlink:href="#y" transform="translate(8,8) scale(0.02)" xmlns:xlink="http://www.w3.org/1999/xlink" />
<use xlink:href="#y" transform="translate(8,8) scale(0.02)" xmlns:xlink="http://www.w3.org/1999/xlink" />
</svg></lang>
</svg></syntaxhighlight>


====SVG (harder cheating)====
====SVG (harder cheating)====
{{trans|Raku}}
{{trans|Raku}}


<lang vbnet>Module Program
<syntaxhighlight lang="vbnet">Module Program
Sub Main()
Sub Main()
Console.OutputEncoding = Text.Encoding.Unicode
Console.OutputEncoding = Text.Encoding.Unicode
Line 1,378: Line 1,378:
Console.WriteLine(<div><%= cheat_harder(700) %><%= cheat_harder(350) %></div>)
Console.WriteLine(<div><%= cheat_harder(700) %><%= cheat_harder(350) %></div>)
End Sub
End Sub
End Module</lang>
End Module</syntaxhighlight>


{{out}}
{{out}}
<lang html5><div>
<syntaxhighlight lang="html5"><div>
<span style="font-size:700%;">☯</span>
<span style="font-size:700%;">☯</span>
<span style="font-size:350%;">☯</span>
<span style="font-size:350%;">☯</span>
</div></lang>
</div></syntaxhighlight>


Rendered by RosettaCode (MediaWiki):
Rendered by RosettaCode (MediaWiki):
Line 1,391: Line 1,391:


==={{header|Yabasic}}===
==={{header|Yabasic}}===
<lang Yabasic>open window 640, 480
<syntaxhighlight lang="yabasic">open window 640, 480


color 0,0,0
color 0,0,0
Line 1,439: Line 1,439:
lx=x : rx=x : y=oy : m=-1 // m=-1 makes go upwards
lx=x : rx=x : y=oy : m=-1 // m=-1 makes go upwards
next t
next t
end sub</lang>
end sub</syntaxhighlight>
Other solution:
Other solution:
<lang Yabasic>open window 640, 480
<syntaxhighlight lang="yabasic">open window 640, 480
backcolor 255,0,0
backcolor 255,0,0
color 0,0,0
color 0,0,0
Line 1,461: Line 1,461:
pause .025
pause .025
next n
next n
end sub</lang>
end sub</syntaxhighlight>


==={{header|ZX Spectrum Basic}}===
==={{header|ZX Spectrum Basic}}===
Line 1,468: Line 1,468:
This could be done with fewer fills by defining the outline with arcs instead of circles, but it'd be just as "fast".
This could be done with fewer fills by defining the outline with arcs instead of circles, but it'd be just as "fast".


<lang zxbasic>10 CLS
<syntaxhighlight lang="zxbasic">10 CLS
20 LET i=0
20 LET i=0
30 PRINT "Recommended size is a multiple of 4 between 40 and 80": REM smaller sizes don't render properly and larger ones don't fit
30 PRINT "Recommended size is a multiple of 4 between 40 and 80": REM smaller sizes don't render properly and larger ones don't fit
Line 1,539: Line 1,539:
9070 NEXT x
9070 NEXT x
9080 NEXT y
9080 NEXT y
9090 RETURN</lang>
9090 RETURN</syntaxhighlight>


[https://i.imgur.com/J1DK7qQl.png Resultant image at Imgur] (uses size=40 and position=40, then size=80 and position=160)
[https://i.imgur.com/J1DK7qQl.png Resultant image at Imgur] (uses size=40 and position=40, then size=80 and position=160)


=={{header|BCPL}}==
=={{header|BCPL}}==
<lang bcpl>get "libhdr"
<syntaxhighlight lang="bcpl">get "libhdr"


let circle(x, y, c, r) = (r*r) >= (x/2) * (x/2) + (y-c) * (y-c)
let circle(x, y, c, r) = (r*r) >= (x/2) * (x/2) + (y-c) * (y-c)
Line 1,566: Line 1,566:
$( yinyang(4)
$( yinyang(4)
yinyang(8)
yinyang(8)
$) </lang>
$) </syntaxhighlight>
{{out}}
{{out}}
<pre> ...
<pre> ...
Line 1,597: Line 1,597:
{{trans|PicoLisp}}
{{trans|PicoLisp}}
The radius is specified by the first value on the stack - set to 10 (55+) in this example.
The radius is specified by the first value on the stack - set to 10 (55+) in this example.
<lang befunge>55+:#. 00p:2*10p:2/20p6/30p01v
<syntaxhighlight lang="befunge">55+:#. 00p:2*10p:2/20p6/30p01v
@#!`g01:+1g07,+55$<v0-g010p07_
@#!`g01:+1g07,+55$<v0-g010p07_
0g-20g+:*+30g:*`v ^_:2/:*:70g0
0g-20g+:*+30g:*`v ^_:2/:*:70g0
Line 1,604: Line 1,604:
2+*:-g02-g00g07:_ 1v v!`*:g0
2+*:-g02-g00g07:_ 1v v!`*:g0
g-:*+00g:*`#v_$:0`!0\v0_:70g00
g-:*+00g:*`#v_$:0`!0\v0_:70g00
0#+g#1,#$< > 2 #^>#g>#04#1+#:</lang>
0#+g#1,#$< > 2 #^>#g>#04#1+#:</syntaxhighlight>


{{out}}
{{out}}
Line 1,631: Line 1,631:
=={{header|C}}==
=={{header|C}}==
Writes to stdout a SVG file with two yin-yangs (no, it's really just that big): [[File:yinyang-C.svg]]
Writes to stdout a SVG file with two yin-yangs (no, it's really just that big): [[File:yinyang-C.svg]]
<lang C>#include <stdio.h>
<syntaxhighlight lang="c">#include <stdio.h>


void draw_yinyang(int trans, double scale)
void draw_yinyang(int trans, double scale)
Line 1,660: Line 1,660:
printf("</svg>");
printf("</svg>");
return 0;
return 0;
}</lang>
}</syntaxhighlight>


=={{header|C++}}==
=={{header|C++}}==
{{trans|Java}}
{{trans|Java}}
<lang cpp>#include <iostream>
<syntaxhighlight lang="cpp">#include <iostream>


bool circle(int x, int y, int c, int r) {
bool circle(int x, int y, int c, int r) {
Line 1,705: Line 1,705:
yinYang(18);
yinYang(18);
return 0;
return 0;
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre> ...
<pre> ...
Line 1,750: Line 1,750:
(Cleaned up)
(Cleaned up)


<lang csharp>
<syntaxhighlight lang="csharp">
public partial class Form1 : Form
public partial class Form1 : Form
{
{
Line 1,782: Line 1,782:
if (hasOutline) g.DrawEllipse(Pens.Black, pt.X, pt.Y, width, width);
if (hasOutline) g.DrawEllipse(Pens.Black, pt.X, pt.Y, width, width);
}
}
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 1,794: Line 1,794:


=={{header|CLU}}==
=={{header|CLU}}==
<lang clu>taijitu = cluster is make
<syntaxhighlight lang="clu">taijitu = cluster is make
rep = null
rep = null
Line 1,828: Line 1,828:
stream$putl(po, taijitu$make(4))
stream$putl(po, taijitu$make(4))
stream$putl(po, taijitu$make(8))
stream$putl(po, taijitu$make(8))
end start_up</lang>
end start_up</syntaxhighlight>
{{out}}
{{out}}
<pre> ..
<pre> ..
Line 1,860: Line 1,860:
=={{header|D}}==
=={{header|D}}==
{{trans|Python}}
{{trans|Python}}
<lang d>import std.stdio, std.algorithm, std.array, std.math, std.range,
<syntaxhighlight lang="d">import std.stdio, std.algorithm, std.array, std.math, std.range,
std.conv, std.typecons;
std.conv, std.typecons;


Line 1,896: Line 1,896:
2.yinYang.writeln;
2.yinYang.writeln;
1.yinYang.writeln;
1.yinYang.writeln;
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre> .
<pre> .
Line 1,939: Line 1,939:
A simpler alternative version:
A simpler alternative version:
{{trans|PicoLisp}}
{{trans|PicoLisp}}
<lang d>void yinYang(in int r) {
<syntaxhighlight lang="d">void yinYang(in int r) {
import std.stdio, std.math;
import std.stdio, std.math;


Line 1,959: Line 1,959:
void main() {
void main() {
16.yinYang;
16.yinYang;
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre> ...
<pre> ...
Line 1,997: Line 1,997:
=={{header|Delphi}}==
=={{header|Delphi}}==
Instructions: Create an empty project. Paste code below and adjust the interface section for the form. Then assign 'FormCreate' to TForm1.OnCreate and 'FormPaint' to TForm1.OnPaint.
Instructions: Create an empty project. Paste code below and adjust the interface section for the form. Then assign 'FormCreate' to TForm1.OnCreate and 'FormPaint' to TForm1.OnPaint.
<lang delphi>procedure DrawYinAndYang(Canv: TCanvas; R: TRect);
<syntaxhighlight lang="delphi">procedure DrawYinAndYang(Canv: TCanvas; R: TRect);
begin
begin
Canv.Brush.Color := clWhite;
Canv.Brush.Color := clWhite;
Line 2,048: Line 2,048:
DrawYinAndYang(Canvas, R);
DrawYinAndYang(Canvas, R);
end;
end;
</syntaxhighlight>
</lang>


{{output?}}
{{output?}}
Line 2,055: Line 2,055:


{{Trans|D}}
{{Trans|D}}
<lang delphi>type
<syntaxhighlight lang="delphi">type
TColorFuncX = function (x : Integer) : Integer;
TColorFuncX = function (x : Integer) : Integer;


Line 2,131: Line 2,131:
sq := new TSquareBoard(1);
sq := new TSquareBoard(1);
sq.YinYang;
sq.YinYang;
sq.Print;</lang>
sq.Print;</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 2,188: Line 2,188:
{{works with|gforth|0.7.3}}
{{works with|gforth|0.7.3}}


<lang forth>: circle ( x y r h -- f )
<syntaxhighlight lang="forth">: circle ( x y r h -- f )
rot - dup *
rot - dup *
rot dup * +
rot dup * +
Line 2,213: Line 2,213:
loop
loop
loop drop
loop drop
;</lang>
;</syntaxhighlight>


{{out}}
{{out}}
Line 2,236: Line 2,236:
{{works with|4tH v3.64}}
{{works with|4tH v3.64}}
4tH has a graphics library, which makes it quite easy to generate this picture using graphics commands only.
4tH has a graphics library, which makes it quite easy to generate this picture using graphics commands only.
<lang>[PRAGMA] usestackflood \ don't use additional memory for fill
<syntaxhighlight lang="text">[PRAGMA] usestackflood \ don't use additional memory for fill
include lib/graphics.4th \ load the graphics library
include lib/graphics.4th \ load the graphics library
include lib/gcircle.4th \ we need a full circle
include lib/gcircle.4th \ we need a full circle
Line 2,257: Line 2,257:
300 300 295 circle \ let's make it a double line width
300 300 295 circle \ let's make it a double line width


s" gyinyang.ppm" save_image \ save the image</lang>
s" gyinyang.ppm" save_image \ save the image</syntaxhighlight>


=={{header|Go}}==
=={{header|Go}}==
There are some emerging third-party 2D graphics libraries for Go; meanwhile, here is an SVG solution using only standard libraries.
There are some emerging third-party 2D graphics libraries for Go; meanwhile, here is an SVG solution using only standard libraries.
[[file:GoYinYang.svg|right]]
[[file:GoYinYang.svg|right]]
<lang go>package main
<syntaxhighlight lang="go">package main


import (
import (
Line 2,313: Line 2,313:
}
}
f.Close()
f.Close()
}</lang>
}</syntaxhighlight>


=={{header|Haskell}}==
=={{header|Haskell}}==
Line 2,321: Line 2,321:
Depending on the command-line arguments, the program can generate SVG, PNG, PDF or PostScript output.
Depending on the command-line arguments, the program can generate SVG, PNG, PDF or PostScript output.
The sample output was created with the command <tt>yinyang -o YinYang-Haskell.svg</tt>.
The sample output was created with the command <tt>yinyang -o YinYang-Haskell.svg</tt>.
<lang haskell>{-# LANGUAGE NoMonomorphismRestriction #-}
<syntaxhighlight lang="haskell">{-# LANGUAGE NoMonomorphismRestriction #-}


import Diagrams.Prelude
import Diagrams.Prelude
Line 2,338: Line 2,338:
main = defaultMain $
main = defaultMain $
pad 1.1 $
pad 1.1 $
beside (2,-1) yinyang (yinyang # scale (1/4))</lang>
beside (2,-1) yinyang (yinyang # scale (1/4))</syntaxhighlight>


=={{header|Icon}} and {{header|Unicon}}==
=={{header|Icon}} and {{header|Unicon}}==
[[File:YinYang-unicon.PNG|thumb|Sample Output]]
[[File:YinYang-unicon.PNG|thumb|Sample Output]]
<lang Icon>link graphics
<syntaxhighlight lang="icon">link graphics


procedure main()
procedure main()
Line 2,364: Line 2,364:
WAttrib(W,"fg="||lhs) & FillCircle(W,C,C-R/2,R/8) # dots
WAttrib(W,"fg="||lhs) & FillCircle(W,C,C-R/2,R/8) # dots
WAttrib(W,"fg="||rhs) & FillCircle(W,C,C+R/2,R/8)
WAttrib(W,"fg="||rhs) & FillCircle(W,C,C+R/2,R/8)
end</lang>
end</syntaxhighlight>


{{libheader|Icon Programming Library}}
{{libheader|Icon Programming Library}}
Line 2,373: Line 2,373:
Based on the Python implementation:
Based on the Python implementation:


<lang j>yinyang=:3 :0
<syntaxhighlight lang="j">yinyang=:3 :0
radii=. y*1 3 6
radii=. y*1 3 6
ranges=. i:each radii
ranges=. i:each radii
Line 2,386: Line 2,386:
M=. '.' ((_3 {:: cInds) <@:+"1 offset)} M
M=. '.' ((_3 {:: cInds) <@:+"1 offset)} M
M=. '*' ((_3 {:: cInds) <@:-"1 offset)} M
M=. '*' ((_3 {:: cInds) <@:-"1 offset)} M
)</lang>
)</syntaxhighlight>


Note: although the structure of this program is based on the python implementation, some [[Yin_and_yang/J|details]] are different. In particular, in the python implementation, the elements of squares and circles have no x,y structure -- they are flat list of coordinates.
Note: although the structure of this program is based on the python implementation, some [[Yin_and_yang/J|details]] are different. In particular, in the python implementation, the elements of squares and circles have no x,y structure -- they are flat list of coordinates.
Line 2,398: Line 2,398:
Example use:
Example use:


<lang> yinyang 1
<syntaxhighlight lang="text"> yinyang 1
.
.
......*
......*
Line 2,437: Line 2,437:
..***********
..***********
.********
.********
* </lang>
* </syntaxhighlight>


=={{header|Java}}==
=={{header|Java}}==
Line 2,445: Line 2,445:
[[File:Java-yinyang-240.png | right]]
[[File:Java-yinyang-240.png | right]]


<lang java>package org.rosettacode.yinandyang;
<syntaxhighlight lang="java">package org.rosettacode.yinandyang;


import java.awt.Color;
import java.awt.Color;
Line 2,525: Line 2,525:
frame.setVisible(true);
frame.setVisible(true);
}
}
}</lang>
}</syntaxhighlight>


===Text===
===Text===
Line 2,531: Line 2,531:
{{works with|Java|1.8}}
{{works with|Java|1.8}}


<lang java>import java.util.Collection;
<syntaxhighlight lang="java">import java.util.Collection;
import java.util.Map;
import java.util.Map;
import java.util.Optional;
import java.util.Optional;
Line 2,613: Line 2,613:
}
}
}
}
</syntaxhighlight>
</lang>


Test:
Test:
Line 2,659: Line 2,659:
=={{header|JavaScript}}==
=={{header|JavaScript}}==
Another way, a more JavaScript-style way.
Another way, a more JavaScript-style way.
<syntaxhighlight lang="javascript">
<lang JavaScript>
function Arc(posX,posY,radius,startAngle,endAngle,color){//Angle in radians.
function Arc(posX,posY,radius,startAngle,endAngle,color){//Angle in radians.
this.posX=posX;
this.posX=posX;
Line 2,719: Line 2,719:
YingYang[0];
YingYang[0];
//In construction.
//In construction.
</syntaxhighlight>
</lang>


===Text===
===Text===
{{trans|ALGOL 68}}
{{trans|ALGOL 68}}
<lang JavaScript>YinYang = (function () {
<syntaxhighlight lang="javascript">YinYang = (function () {
var scale_x = 2,
var scale_x = 2,
scale_y = 1,
scale_y = 1,
Line 2,788: Line 2,788:
})()
})()
console.log(YinYang(17))
console.log(YinYang(17))
console.log(YinYang(8))</lang>
console.log(YinYang(8))</syntaxhighlight>


===SVG===
===SVG===
Line 2,795: Line 2,795:
This is a SVG embedded in a HTML document;
This is a SVG embedded in a HTML document;
it can be isolated from the HTML document too, making it a standalone SVG
it can be isolated from the HTML document too, making it a standalone SVG
<lang JavaScript><!DOCTYPE html>
<syntaxhighlight lang="javascript"><!DOCTYPE html>
<html>
<html>


Line 2,898: Line 2,898:
</head>
</head>


</html></lang>
</html></syntaxhighlight>


=={{header|jq}}==
=={{header|jq}}==
Line 2,905: Line 2,905:
The jq program presented here is adapted from the C version and produces the same image:
The jq program presented here is adapted from the C version and produces the same image:
[[File:yinyang-C.svg]]
[[File:yinyang-C.svg]]
<syntaxhighlight lang="jq">
<lang jq>
def svg:
def svg:
"<svg width='100%' height='100%' version='1.1'
"<svg width='100%' height='100%' version='1.1'
Line 2,934: Line 2,934:
"</svg>" ;
"</svg>" ;


draw</lang>
draw</syntaxhighlight>
To view the image, store the output in a file:
To view the image, store the output in a file:
<lang sh>$ jq -M -r -n -f yin_and_yang.jq > yin_and_yang.svg</lang>
<syntaxhighlight lang="sh">$ jq -M -r -n -f yin_and_yang.jq > yin_and_yang.svg</syntaxhighlight>
The image can then be viewed in a browser.
The image can then be viewed in a browser.


Line 2,943: Line 2,943:
{{trans|Python}}
{{trans|Python}}


<lang julia>function yinyang(n::Int=3)
<syntaxhighlight lang="julia">function yinyang(n::Int=3)
radii = (i * n for i in (1, 3, 6))
radii = (i * n for i in (1, 3, 6))
ranges = collect(collect(-r:r) for r in radii)
ranges = collect(collect(-r:r) for r in radii)
Line 2,963: Line 2,963:


println(yinyang(4))
println(yinyang(4))
</syntaxhighlight>
</lang>


=={{header|Kotlin}}==
=={{header|Kotlin}}==
This is based on the Java entry but I've adjusted the code so that the program displays big and small yin-yangs of a predetermined size in the same frame. Consequently, the program only needs to be run once and doesn't require a command line argument.
This is based on the Java entry but I've adjusted the code so that the program displays big and small yin-yangs of a predetermined size in the same frame. Consequently, the program only needs to be run once and doesn't require a command line argument.
<lang scala>// version 1.1.2
<syntaxhighlight lang="scala">// version 1.1.2


import java.awt.Color
import java.awt.Color
Line 3,039: Line 3,039:
isVisible = true
isVisible = true
}
}
}</lang>
}</syntaxhighlight>


=={{header|Lambdatalk}}==
=={{header|Lambdatalk}}==


<syntaxhighlight lang="scheme">
<lang Scheme>
{{SVG 580 580}
{{SVG 580 580}
{YY 145 145 300}
{YY 145 145 300}
Line 3,082: Line 3,082:
http://lambdaway.free.fr/lambdawalks/data/lambdatalk_yinyang.png
http://lambdaway.free.fr/lambdawalks/data/lambdatalk_yinyang.png


</syntaxhighlight>
</lang>


=={{header|Logo}}==
=={{header|Logo}}==
Line 3,089: Line 3,089:
{{works with|MSW_Logo|6.5b}}
{{works with|MSW_Logo|6.5b}}


<lang logo>to taijitu :r
<syntaxhighlight lang="logo">to taijitu :r
; Draw a classic Taoist taijitu of the given radius centered on the current
; Draw a classic Taoist taijitu of the given radius centered on the current
; turtle position. The "eyes" are placed along the turtle's heading, the
; turtle position. The "eyes" are placed along the turtle's heading, the
Line 3,148: Line 3,148:
forward 150
forward 150
pendown
pendown
taijitu 75</lang>
taijitu 75</syntaxhighlight>


=={{header|Lua}}==
=={{header|Lua}}==
{{trans|C++}}
{{trans|C++}}
<lang lua>function circle(x, y, c, r)
<syntaxhighlight lang="lua">function circle(x, y, c, r)
return (r * r) >= (x * x) / 4 + ((y - c) * (y - c))
return (r * r) >= (x * x) / 4 + ((y - c) * (y - c))
end
end
Line 3,188: Line 3,188:
end
end


yinYang(18)</lang>
yinYang(18)</syntaxhighlight>
{{out}}
{{out}}
<pre> .
<pre> .
Line 3,229: Line 3,229:


=={{header|Maple}}==
=={{header|Maple}}==
<syntaxhighlight lang="maple">
<lang Maple>
with(plottools):
with(plottools):
with(plots):
with(plots):
Line 3,241: Line 3,241:
scaling = constrained, axes = none
scaling = constrained, axes = none
);
);
</syntaxhighlight>
</lang>


=={{header|Mathematica}} / {{header|Wolfram Language}}==
=={{header|Mathematica}} / {{header|Wolfram Language}}==
[[File:Mathca.png|thumb|200px]]
[[File:Mathca.png|thumb|200px]]
Mathematica's ability to symbolically build up graphics is often underrated. The following function will create a yin-yang symbol with the parameter size indicating the diameter in multiples of 40 pixels.
Mathematica's ability to symbolically build up graphics is often underrated. The following function will create a yin-yang symbol with the parameter size indicating the diameter in multiples of 40 pixels.
<lang Mathematica>YinYang[size_] :=
<syntaxhighlight lang="mathematica">YinYang[size_] :=
Graphics[{{Circle[{0, 0}, 2]}, {Disk[{0, 0},
Graphics[{{Circle[{0, 0}, 2]}, {Disk[{0, 0},
2, {90 Degree, -90 Degree}]}, {White, Disk[{0, 1}, 1]}, {Black,
2, {90 Degree, -90 Degree}]}, {White, Disk[{0, 1}, 1]}, {Black,
Disk[{0, -1}, 1]}, {Black, Disk[{0, 1}, 1/4]}, {White,
Disk[{0, -1}, 1]}, {Black, Disk[{0, 1}, 1/4]}, {White,
Disk[{0, -1}, 1/4]}}, ImageSize -> 40 size]</lang>
Disk[{0, -1}, 1/4]}}, ImageSize -> 40 size]</syntaxhighlight>


=={{header|Metapost}}==
=={{header|Metapost}}==
[[File:Mp-Yingyang.jpg||200px|thumb|right|Metapost output (once converted to jpg)]]
[[File:Mp-Yingyang.jpg||200px|thumb|right|Metapost output (once converted to jpg)]]
The "function" yinyang returns a picture (a primitive type) that can be drawn (and transformed of course in any way)
The "function" yinyang returns a picture (a primitive type) that can be drawn (and transformed of course in any way)
<lang metapost>vardef yinyang(expr u) =
<syntaxhighlight lang="metapost">vardef yinyang(expr u) =
picture pic_;
picture pic_;
path p_;
path p_;
Line 3,278: Line 3,278:
endfig;
endfig;


end.</lang>
end.</syntaxhighlight>


=={{header|Modula-2}}==
=={{header|Modula-2}}==
<lang modula2>MODULE Taijitu;
<syntaxhighlight lang="modula2">MODULE Taijitu;
FROM InOut IMPORT Write, WriteLn;
FROM InOut IMPORT Write, WriteLn;


Line 3,318: Line 3,318:
WriteLn();
WriteLn();
YinYang(8);
YinYang(8);
END Taijitu.</lang>
END Taijitu.</syntaxhighlight>
{{out}}
{{out}}
<pre> ..
<pre> ..
Line 3,351: Line 3,351:
Writes an SVG document to standard output: [[File:yinyang-NRX.svg]]
Writes an SVG document to standard output: [[File:yinyang-NRX.svg]]
{{trans|C}}
{{trans|C}}
<lang NetRexx>/* NetRexx */
<syntaxhighlight lang="netrexx">/* NetRexx */


options replace format comments java crossref savelog symbols binary
options replace format comments java crossref savelog symbols binary
Line 3,381: Line 3,381:
yy = String.format(" <use xlink:href='#y' transform='translate(%d,%d) scale(%g)'/>", -
yy = String.format(" <use xlink:href='#y' transform='translate(%d,%d) scale(%g)'/>", -
[Object Integer(trans), Integer(trans), Double(scale)])
[Object Integer(trans), Integer(trans), Double(scale)])
return yy</lang>
return yy</syntaxhighlight>


=={{header|Nim}}==
=={{header|Nim}}==
{{trans|Ada}}
{{trans|Ada}}
{{libheader|gintro}}
{{libheader|gintro}}
<lang Nim>import gintro/cairo
<syntaxhighlight lang="nim">import gintro/cairo


proc draw(ctx: Context; x, y, r: float) =
proc draw(ctx: Context; x, y, r: float) =
Line 3,409: Line 3,409:
context.draw(35, 35, 30)
context.draw(35, 35, 30)
let status = surface.writeToPng("yin-yang.png")
let status = surface.writeToPng("yin-yang.png")
assert status == Status.success</lang>
assert status == Status.success</syntaxhighlight>


=={{header|OCaml}}==
=={{header|OCaml}}==


<lang ocaml>open Graphics
<syntaxhighlight lang="ocaml">open Graphics


let draw_yinyang x y radius black white =
let draw_yinyang x y radius black white =
Line 3,444: Line 3,444:
draw_yinyang w (h*2) (r*2) black white;
draw_yinyang w (h*2) (r*2) black white;
draw_yinyang (w*2) h r blue magenta;
draw_yinyang (w*2) h r blue magenta;
ignore(read_key())</lang>
ignore(read_key())</syntaxhighlight>


run with:
run with:
Line 3,450: Line 3,450:


=={{header|PARI/GP}}==
=={{header|PARI/GP}}==
<lang pari>YinYang(r)={ for(y=-r,r, print(concat(apply( x->
<syntaxhighlight lang="pari">YinYang(r)={ for(y=-r,r, print(concat(apply( x->
if( x^2+y^2>r^2, " ",
if( x^2+y^2>r^2, " ",
[y<0,y>0,x>0][logint((x^2+(abs(y)-r/2)^2)<<8\r^2+1,2)\3+1], "#", "."
[y<0,y>0,x>0][logint((x^2+(abs(y)-r/2)^2)<<8\r^2+1,2)\3+1], "#", "."
), [-r..r]
), [-r..r]
))))
))))
}</lang>
}</syntaxhighlight>


If outside the big circle, we leave blank, else we distinguish three cases depending on D = (x/r)^2+(|y/r|-1/2)^2 or rather log_2(D)+8: Less than 3 (D < 1/32: small circles), black iff y < 0; between 3 and 6 (1/32 < D < 1/4: rings around circles), black iff y > 0; beyond 6 (D > 1/4: left or right half outside rings), black iff x > 0. In all other cases white.
If outside the big circle, we leave blank, else we distinguish three cases depending on D = (x/r)^2+(|y/r|-1/2)^2 or rather log_2(D)+8: Less than 3 (D < 1/32: small circles), black iff y < 0; between 3 and 6 (1/32 < D < 1/4: rings around circles), black iff y > 0; beyond 6 (D > 1/4: left or right half outside rings), black iff x > 0. In all other cases white.
Line 3,464: Line 3,464:


{{Trans|JavaScript}}
{{Trans|JavaScript}}
<lang Pascal>//Written for TU Berlin
<syntaxhighlight lang="pascal">//Written for TU Berlin
//Compiled with fpc
//Compiled with fpc
Program yingyang;
Program yingyang;
Line 3,530: Line 3,530:




</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 3,578: Line 3,578:
[[File:yinyang-perl.svg|thumb]]
[[File:yinyang-perl.svg|thumb]]


<lang perl>sub circle {
<syntaxhighlight lang="perl">sub circle {
my ($radius, $cx, $cy, $fill, $stroke) = @_;
my ($radius, $cx, $cy, $fill, $stroke) = @_;
print "<circle cx='$cx' cy='$cy' r='$radius' ",
print "<circle cx='$cx' cy='$cy' r='$radius' ",
Line 3,631: Line 3,631:
yin_yang(100, 500, 500);
yin_yang(100, 500, 500);


print "</svg>"</lang>
print "</svg>"</syntaxhighlight>


Messy code. Note that the larger yin-yang is drawn recursively.
Messy code. Note that the larger yin-yang is drawn recursively.
Line 3,639: Line 3,639:
{{libheader|Phix/online}}
{{libheader|Phix/online}}
You can run this online [http://phix.x10.mx/p2js/yinyang.htm here].
You can run this online [http://phix.x10.mx/p2js/yinyang.htm here].
<!--<lang Phix>(phixonline)-->
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #000080;font-style:italic;">--
<span style="color: #000080;font-style:italic;">--
-- demo\rosetta\Yin_and_yang.exw
-- demo\rosetta\Yin_and_yang.exw
Line 3,716: Line 3,716:
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<!--</lang>-->
<!--</syntaxhighlight>-->


=={{header|PHL}}==
=={{header|PHL}}==
Line 3,722: Line 3,722:
{{trans|ALGOL 68}}
{{trans|ALGOL 68}}


<lang phl>module circles;
<syntaxhighlight lang="phl">module circles;


extern printf;
extern printf;
Line 3,787: Line 3,787:
print_yin_yang(8);
print_yin_yang(8);
return 0;
return 0;
]</lang>
]</syntaxhighlight>


{{out}}
{{out}}
Line 3,847: Line 3,847:


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==
<lang PicoLisp>(de circle (X Y C R)
<syntaxhighlight lang="picolisp">(de circle (X Y C R)
(>=
(>=
(* R R)
(* R R)
Line 3,870: Line 3,870:
(if (lt0 X) "." "#") )
(if (lt0 X) "." "#") )
(T " ") ) ) )
(T " ") ) ) )
(prinl) ) )</lang>
(prinl) ) )</syntaxhighlight>


{{out|Test}}
{{out|Test}}
Line 3,915: Line 3,915:


=={{header|Plain English}}==
=={{header|Plain English}}==
<lang plainenglish>To run:
<syntaxhighlight lang="plainenglish">To run:
Start up.
Start up.
Clear the screen to the gray color.
Clear the screen to the gray color.
Line 3,946: Line 3,946:
Unmask everything.
Unmask everything.
Use the fat pen.
Use the fat pen.
Draw the ellipse.</lang>
Draw the ellipse.</syntaxhighlight>
{{out}}
{{out}}
[https://commons.wikimedia.org/wiki/File:Taijitu_symbols_drawn_with_Plain_English.png]
[https://commons.wikimedia.org/wiki/File:Taijitu_symbols_drawn_with_Plain_English.png]


=={{header|PL/I}}==
=={{header|PL/I}}==
<lang pli>yinyang: procedure options(main);
<syntaxhighlight lang="pli">yinyang: procedure options(main);
yinyang: procedure(r);
yinyang: procedure(r);
circle: procedure(x, y, c, r) returns(bit);
circle: procedure(x, y, c, r) returns(bit);
Line 3,983: Line 3,983:
put skip;
put skip;
call yinyang(8);
call yinyang(8);
end yinyang;</lang>
end yinyang;</syntaxhighlight>
{{out}}
{{out}}
<pre> ...
<pre> ...
Line 4,015: Line 4,015:
=={{header|PostScript}}==
=={{header|PostScript}}==
{{out}} [[File:PSyinyang.png|thumb]]
{{out}} [[File:PSyinyang.png|thumb]]
<lang PostScript>%!PS-Adobe-3.0
<syntaxhighlight lang="postscript">%!PS-Adobe-3.0
%%BoundingBox: 0 0 400 400
%%BoundingBox: 0 0 400 400


Line 4,054: Line 4,054:
6 circ 220 180 dis
6 circ 220 180 dis
showpage
showpage
%%EOF</lang>
%%EOF</syntaxhighlight>


=={{header|POV-Ray}}==
=={{header|POV-Ray}}==
[[File:Yys.png|thumb]]
[[File:Yys.png|thumb]]


<syntaxhighlight lang="pov-ray">
<lang POV-Ray>
// ====== General Scene setup ======
// ====== General Scene setup ======
#version 3.7;
#version 3.7;
Line 4,128: Line 4,128:


#declare scl = scl*0.85;
#declare scl = scl*0.85;
#end</lang>
#end</syntaxhighlight>


=={{header|Prolog}}==
=={{header|Prolog}}==
Works with SWI-Prolog and XPCE.
Works with SWI-Prolog and XPCE.


<lang Prolog>ying_yang(N) :-
<syntaxhighlight lang="prolog">ying_yang(N) :-
R is N * 100,
R is N * 100,
sformat(Title, 'Yin Yang ~w', [N]),
sformat(Title, 'Yin Yang ~w', [N]),
Line 4,188: Line 4,188:
send(P, fill_pattern, Col).
send(P, fill_pattern, Col).


:- pce_end_class.</lang>
:- pce_end_class.</syntaxhighlight>
{{out}}
{{out}}
<pre> ?- ying_yang(1).
<pre> ?- ying_yang(1).
Line 4,203: Line 4,203:
an ASCII representation of the Yin yang symbol.
an ASCII representation of the Yin yang symbol.
{{works with|Python|3.x}}
{{works with|Python|3.x}}
<lang python>import math
<syntaxhighlight lang="python">import math
def yinyang(n=3):
def yinyang(n=3):
radii = [i * n for i in (1, 3, 6)]
radii = [i * n for i in (1, 3, 6)]
Line 4,223: Line 4,223:
m[(x,y+3*n)] = '·'
m[(x,y+3*n)] = '·'
m[(x,y-3*n)] = '*'
m[(x,y-3*n)] = '*'
return '\n'.join(''.join(m[(x,y)] for x in reversed(ranges[-1])) for y in ranges[-1])</lang>
return '\n'.join(''.join(m[(x,y)] for x in reversed(ranges[-1])) for y in ranges[-1])</syntaxhighlight>


;Sample generated symbols for <code>n = 2</code> and <code>n = 3</code>:
;Sample generated symbols for <code>n = 2</code> and <code>n = 3</code>:
Line 4,271: Line 4,271:
This was inspired by the Logo example but diverged as some of the Python turtle graphics primitives such as filling and the drawing of arcs work differently.
This was inspired by the Logo example but diverged as some of the Python turtle graphics primitives such as filling and the drawing of arcs work differently.
[[File:Yinyang.GIF||200px|thumb|right|Python turtle graphics program output]]
[[File:Yinyang.GIF||200px|thumb|right|Python turtle graphics program output]]
<lang python>from turtle import *
<syntaxhighlight lang="python">from turtle import *


mode('logo')
mode('logo')
Line 4,323: Line 4,323:
goto(-150, -150)
goto(-150, -150)
taijitu(100)
taijitu(100)
hideturtle()</lang>
hideturtle()</syntaxhighlight>


=={{header|Quackery}}==
=={{header|Quackery}}==
<lang Quackery>[ $ "turtleduck.qky" loadfile ] now!
<syntaxhighlight lang="quackery">[ $ "turtleduck.qky" loadfile ] now!


[ -1 4 turn
[ -1 4 turn
Line 4,355: Line 4,355:
100 1 yinyang
100 1 yinyang
420 1 fly
420 1 fly
300 1 yinyang</lang>
300 1 yinyang</syntaxhighlight>


{{output}}
{{output}}
Line 4,363: Line 4,363:
=={{header|R}}==
=={{header|R}}==
[[File:yin_yang.png|thumb|Output of this R program]]
[[File:yin_yang.png|thumb|Output of this R program]]
<lang r>plot.yin.yang <- function(x=5, y=5, r=3, s=10, add=F){
<syntaxhighlight lang="r">plot.yin.yang <- function(x=5, y=5, r=3, s=10, add=F){
suppressMessages(require("plotrix"))
suppressMessages(require("plotrix"))
if(!add) plot(1:10, type="n", xlim=c(0,s), ylim=c(0,s), xlab="", ylab="", xaxt="n", yaxt="n", bty="n", asp=1)
if(!add) plot(1:10, type="n", xlim=c(0,s), ylim=c(0,s), xlab="", ylab="", xaxt="n", yaxt="n", bty="n", asp=1)
Line 4,377: Line 4,377:
plot.yin.yang()
plot.yin.yang()
plot.yin.yang(1,7,1, add=T)
plot.yin.yang(1,7,1, add=T)
dev.off()</lang>
dev.off()</syntaxhighlight>


=={{header|Racket}}==
=={{header|Racket}}==
[[File:Rosetta-yin-yang.png||200px|thumb|right]]
[[File:Rosetta-yin-yang.png||200px|thumb|right]]
<lang racket>
<syntaxhighlight lang="racket">
#lang racket
#lang racket
(require slideshow/pict)
(require slideshow/pict)
Line 4,402: Line 4,402:


(yin-yang 200)
(yin-yang 200)
</syntaxhighlight>
</lang>


=={{header|Raku}}==
=={{header|Raku}}==
Line 4,410: Line 4,410:
Translation / Modification of C and Perl examples.
Translation / Modification of C and Perl examples.


<lang perl6>sub circle ($rad, $cx, $cy, $fill = 'white', $stroke = 'black' ){
<syntaxhighlight lang="raku" line>sub circle ($rad, $cx, $cy, $fill = 'white', $stroke = 'black' ){
say "<circle cx='$cx' cy='$cy' r='$rad' fill='$fill' stroke='$stroke' stroke-width='1'/>";
say "<circle cx='$cx' cy='$cy' r='$rad' fill='$fill' stroke='$stroke' stroke-width='1'/>";
}
}
Line 4,434: Line 4,434:
yin_yang(50, 300, 300);
yin_yang(50, 300, 300);


say '</svg>';</lang>
say '</svg>';</syntaxhighlight>


Seems like something of a cheat since it relies on a web browser /
Seems like something of a cheat since it relies on a web browser /
Line 4,440: Line 4,440:
If that's the case, we may as well cheat harder. ;-)
If that's the case, we may as well cheat harder. ;-)


<lang perl6>sub cheat_harder ($scale) { "<span style=\"font-size:$scale%;\">&#x262f;</span>"; }
<syntaxhighlight lang="raku" line>sub cheat_harder ($scale) { "<span style=\"font-size:$scale%;\">&#x262f;</span>"; }


say '<div>', cheat_harder(700), cheat_harder(350), '</div>';</lang>
say '<div>', cheat_harder(700), cheat_harder(350), '</div>';</syntaxhighlight>


<div><span style="font-size:700%;">&#x262f;</span><span style="font-size:350%;">&#x262f;</span></div>
<div><span style="font-size:700%;">&#x262f;</span><span style="font-size:350%;">&#x262f;</span></div>
Line 4,448: Line 4,448:
=={{header|Rascal}}==
=={{header|Rascal}}==
[[File:Yinyang.jpg||200px|thumb|right]]
[[File:Yinyang.jpg||200px|thumb|right]]
<lang Rascal>import util::Math;
<syntaxhighlight lang="rascal">import util::Math;
import vis::Render;
import vis::Render;
import vis::Figure;
import vis::Figure;
Line 4,466: Line 4,466:
render(hcat([vcat([overlay([template, black, smallWhite, smallBlack], aspectRatio (1.0)), space(), space()]),
render(hcat([vcat([overlay([template, black, smallWhite, smallBlack], aspectRatio (1.0)), space(), space()]),
overlay([template, black, smallWhite, smallBlack], aspectRatio (1.0))]));
overlay([template, black, smallWhite, smallBlack], aspectRatio (1.0))]));
}</lang>
}</syntaxhighlight>


=={{header|REXX}}==
=={{header|REXX}}==
{{trans|PHL}}
{{trans|PHL}}
Code was added to this REXX program to try to preserve the aspect ratio when displaying the Yin-Yang symbol.
Code was added to this REXX program to try to preserve the aspect ratio when displaying the Yin-Yang symbol.
<lang rexx>/*REXX program creates & displays an ASCII art version of the Yin─Yang (taijitu) symbol.*/
<syntaxhighlight lang="rexx">/*REXX program creates & displays an ASCII art version of the Yin─Yang (taijitu) symbol.*/
parse arg s1 s2 . /*obtain optional arguments from the CL*/
parse arg s1 s2 . /*obtain optional arguments from the CL*/
if s1=='' | s1=="," then s1= 17 /*Not defined? Then use the default. */
if s1=='' | s1=="," then s1= 17 /*Not defined? Then use the default. */
Line 4,495: Line 4,495:
end /*sy*/
end /*sy*/
say strip($, 'T') /*display one line of a Yin─Yang symbol*/
say strip($, 'T') /*display one line of a Yin─Yang symbol*/
end /*sx*/; return</lang>
end /*sx*/; return</syntaxhighlight>
{{out|output|text=&nbsp; when using the inputs of: &nbsp; &nbsp; <tt> 35 &nbsp; 25 </tt>}}
{{out|output|text=&nbsp; when using the inputs of: &nbsp; &nbsp; <tt> 35 &nbsp; 25 </tt>}}


Line 4,629: Line 4,629:
[[File:yin_yang.shoes.png|thumb|Output of this Ruby Shoes program]]
[[File:yin_yang.shoes.png|thumb|Output of this Ruby Shoes program]]
{{libheader|Shoes}}
{{libheader|Shoes}}
<lang ruby>Shoes.app(:width => 470, :height => 380) do
<syntaxhighlight lang="ruby">Shoes.app(:width => 470, :height => 380) do
PI = Shoes::TWO_PI/2
PI = Shoes::TWO_PI/2


Line 4,656: Line 4,656:
yin_yang 190, 190, 360
yin_yang 190, 190, 360
yin_yang 410, 90, 90
yin_yang 410, 90, 90
end</lang>
end</syntaxhighlight>


=={{header|Rust}}==
=={{header|Rust}}==
Line 4,663: Line 4,663:
'''[dependencies]'''<br>
'''[dependencies]'''<br>
svg = "0.10.0"
svg = "0.10.0"
<lang fsharp>use svg::node::element::Path;
<syntaxhighlight lang="fsharp">use svg::node::element::Path;


fn main() {
fn main() {
Line 4,678: Line 4,678:
+ &format!("A{0},{0}{ccw}{r} A{r},{r}{cw}-{r} A{0},{0}{cw}0", r / 2.0); // yang
+ &format!("A{0},{0}{ccw}{r} A{r},{r}{cw}-{r} A{0},{0}{cw}0", r / 2.0); // yang
Path::new().set("d", d).set("fill-rule", "evenodd")
Path::new().set("d", d).set("fill-rule", "evenodd")
}</lang>
}</syntaxhighlight>


=={{header|Scala}}==
=={{header|Scala}}==
{{libheader|Scala}}
{{libheader|Scala}}
<lang scala>import scala.swing.Swing.pair2Dimension
<syntaxhighlight lang="scala">import scala.swing.Swing.pair2Dimension
import scala.swing.{ MainFrame, Panel }
import scala.swing.{ MainFrame, Panel }
import java.awt.{ Color, Graphics2D }
import java.awt.{ Color, Graphics2D }
Line 4,741: Line 4,741:
super.main(args)
super.main(args)
}
}
}</lang>
}</syntaxhighlight>


=={{header|Scilab}}==
=={{header|Scilab}}==
This script uses complex numbers, as in <math>x + i\,y</math>, to represent <math>(x,y)</math> coordinates. [[wp:Euler's formula|Euler's formula]] is used to calculate points over in a circumference. The output is a single graphic window with two images of Yin and yang.
This script uses complex numbers, as in <math>x + i\,y</math>, to represent <math>(x,y)</math> coordinates. [[wp:Euler's formula|Euler's formula]] is used to calculate points over in a circumference. The output is a single graphic window with two images of Yin and yang.


<lang>R = 1; //outer radius of first image
<syntaxhighlight lang="text">R = 1; //outer radius of first image
scale = 0.5; //scale of the second image
scale = 0.5; //scale of the second image


Line 4,834: Line 4,834:


plot2d(real(Arcs(7,:)),imag(Arcs(7,:)));
plot2d(real(Arcs(7,:)),imag(Arcs(7,:)));
set(gca(),'axes_visible',['off','off','off']);</lang>
set(gca(),'axes_visible',['off','off','off']);</syntaxhighlight>


=={{header|Seed7}}==
=={{header|Seed7}}==
[[File:yinandyang.png|thumb|Output of the Seed7 program]]
[[File:yinandyang.png|thumb|Output of the Seed7 program]]
<lang seed7>$ include "seed7_05.s7i";
<syntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "float.s7i";
include "float.s7i";
include "math.s7i";
include "math.s7i";
Line 4,863: Line 4,863:
yinYang(400, 250, 200);
yinYang(400, 250, 200);
readln(KEYBOARD);
readln(KEYBOARD);
end func;</lang>
end func;</syntaxhighlight>


=={{header|Sidef}}==
=={{header|Sidef}}==
{{trans|Raku}}
{{trans|Raku}}
<lang ruby>func circle (rad, cx, cy, fill='white', stroke='black') {
<syntaxhighlight lang="ruby">func circle (rad, cx, cy, fill='white', stroke='black') {
say "<circle cx='#{cx}' cy='#{cy}' r='#{rad}' fill='#{fill}' stroke='#{stroke}' stroke-width='1'/>";
say "<circle cx='#{cx}' cy='#{cy}' r='#{rad}' fill='#{fill}' stroke='#{stroke}' stroke-width='1'/>";
}
}
Line 4,890: Line 4,890:
yin_yang(20, 120, 120);
yin_yang(20, 120, 120);


say '</svg>';</lang>
say '</svg>';</syntaxhighlight>


=={{header|SVG}}==
=={{header|SVG}}==
Line 4,897: Line 4,897:
but we can translate and rescale a shape after defining it.
but we can translate and rescale a shape after defining it.


<lang xml><?xml version="1.0" encoding="UTF-8" standalone="no"?>
<syntaxhighlight lang="xml"><?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
Line 4,930: Line 4,930:
transform="translate(375, 375) scale(400, 400)"/>
transform="translate(375, 375) scale(400, 400)"/>


</svg></lang>
</svg></syntaxhighlight>


=={{header|Tcl}}==
=={{header|Tcl}}==
[[File:yinyang-tcl.gif|thumb|Output of this Tcl program]]
[[File:yinyang-tcl.gif|thumb|Output of this Tcl program]]
{{libheader|Tk}}
{{libheader|Tk}}
<lang tcl>package require Tcl 8.5
<syntaxhighlight lang="tcl">package require Tcl 8.5
package require Tk
package require Tk


Line 4,961: Line 4,961:
pack [canvas .c -width 300 -height 300 -background gray50]
pack [canvas .c -width 300 -height 300 -background gray50]
yinyang .c 110 110 90
yinyang .c 110 110 90
yinyang .c 240 240 40</lang>
yinyang .c 240 240 40</syntaxhighlight>


=={{header|UNIX Shell}}==
=={{header|UNIX Shell}}==
{{works with|Bourne Again SHell}}
{{works with|Bourne Again SHell}}
<lang sh>#!/usr/bin/env bash
<syntaxhighlight lang="sh">#!/usr/bin/env bash
in_circle() { #(cx, cy, r, x y)
in_circle() { #(cx, cy, r, x y)
# return true if the point (x,y) lies within the circle of radius r centered
# return true if the point (x,y) lies within the circle of radius r centered
Line 5,004: Line 5,004:
printf '\n'
printf '\n'
done
done
}</lang>
}</syntaxhighlight>


{{Output}}
{{Output}}
Line 5,070: Line 5,070:
===Text===
===Text===
{{trans|AWK}}
{{trans|AWK}}
<lang ecmascript>var inCircle = Fn.new { |centerX, centerY, radius, x, y|
<syntaxhighlight lang="ecmascript">var inCircle = Fn.new { |centerX, centerY, radius, x, y|
return (x-centerX)*(x-centerX)+(y-centerY)*(y-centerY) <= radius*radius
return (x-centerX)*(x-centerX)+(y-centerY)*(y-centerY) <= radius*radius
}
}
Line 5,110: Line 5,110:


yinAndYang.call(16)
yinAndYang.call(16)
yinAndYang.call(8)</lang>
yinAndYang.call(8)</syntaxhighlight>


{{out}}
{{out}}
Line 5,169: Line 5,169:
{{libheader|DOME}}
{{libheader|DOME}}
With a few minor changes, we can use the same code to draw these symbols in DOME.
With a few minor changes, we can use the same code to draw these symbols in DOME.
<lang ecmascript>import "dome" for Window
<syntaxhighlight lang="ecmascript">import "dome" for Window
import "graphics" for Canvas, Color
import "graphics" for Canvas, Color


Line 5,228: Line 5,228:
}
}


var Game = YinAndYang.new(600, 600)</lang>
var Game = YinAndYang.new(600, 600)</syntaxhighlight>


=={{header|XPL0}}==
=={{header|XPL0}}==
[[File:YinXPL0.png|180px|thumb|right|Output]]
[[File:YinXPL0.png|180px|thumb|right|Output]]
<lang XPL0>include c:\cxpl\codes; \intrinsic 'code' declarations
<syntaxhighlight lang="xpl0">include c:\cxpl\codes; \intrinsic 'code' declarations


def Black=0, Red=4, White=$F;
def Black=0, Red=4, White=$F;
Line 5,260: Line 5,260:
if ChIn(1) then []; \wait for keystroke
if ChIn(1) then []; \wait for keystroke
SetVid(3); \restore normal text mode
SetVid(3); \restore normal text mode
]</lang>
]</syntaxhighlight>


=={{header|zkl}}==
=={{header|zkl}}==
Writes to stdout a SVG file with two yin-yangs.
Writes to stdout a SVG file with two yin-yangs.
<lang zkl>fcn draw_yinyang(trans,scale){
<syntaxhighlight lang="zkl">fcn draw_yinyang(trans,scale){
0'|<use xlink:href="#y" transform="translate(%d,%d) scale(%g)"/>|
0'|<use xlink:href="#y" transform="translate(%d,%d) scale(%g)"/>|
.fmt(trans,trans,scale).print();
.fmt(trans,trans,scale).print();
Line 5,288: Line 5,288:
draw_yinyang(20, 0.05);
draw_yinyang(20, 0.05);
draw_yinyang( 8, 0.02);
draw_yinyang( 8, 0.02);
print("</svg>");</lang>
print("</svg>");</syntaxhighlight>
A here doc (#<<<) could be used to wrap the HTML but, depending on the editor used, the formatting may not be what you want (eg "\n" vs "\r\n").
A here doc (#<<<) could be used to wrap the HTML but, depending on the editor used, the formatting may not be what you want (eg "\n" vs "\r\n").
{{out}}
{{out}}