Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,21 @@
import math
def yinyang(n=3):
radii = [i * n for i in (1, 3, 6)]
ranges = [list(range(-r, r+1)) for r in radii]
squares = [[ (x,y) for x in rnge for y in rnge]
for rnge in ranges]
circles = [[ (x,y) for x,y in sqrpoints
if math.hypot(x,y) <= radius ]
for sqrpoints, radius in zip(squares, radii)]
m = {(x,y):' ' for x,y in squares[-1]}
for x,y in circles[-1]:
m[x,y] = '*'
for x,y in circles[-1]:
if x>0: m[(x,y)] = '·'
for x,y in circles[-2]:
m[(x,y+3*n)] = '*'
m[(x,y-3*n)] = '·'
for x,y in circles[-3]:
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])

View file

@ -0,0 +1,53 @@
from turtle import *
mode('logo')
def taijitu(r):
'''\
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
filled one in front, the open one behind.
'''
# useful derivative values
r2, r4, r8 = (r >> s for s in (1, 2, 3))
# remember where we started
x0, y0 = start = pos()
startcolour = color()
startheading = heading()
color('black', 'black')
# draw outer circle
pendown()
circle(r)
# draw two 'fishes'
begin_fill(); circle(r, 180); circle(r2, 180); circle(-r2, 180); end_fill()
# black 'eye'
setheading(0); penup(); goto(-(r4 + r8) + x0, y0); pendown()
begin_fill(); circle(r8); end_fill()
# white 'eye'
color('white', 'white'); setheading(0); penup(); goto(-(r+r4+r8) + x0, y0); pendown()
begin_fill(); circle(r8); end_fill()
# put the turtle back where it started
penup()
setpos(start)
setheading(startheading)
color(*startcolour)
if __name__ == '__main__':
# demo code to produce image at right
reset()
#hideturtle()
penup()
goto(300, 200)
taijitu(200)
penup()
goto(-150, -150)
taijitu(100)
hideturtle()