yinyang.py

Created by schraf

Created on August 19, 2022

682 Bytes


from turtle import *
from random import random
from kandinsky import set_pixel,fill_rect

BL, WH = (0,0,0), (255,)*3
speed(0)
hideturtle()

def fond():
  fill_rect(0,0,320,222,(20,200,255))
  for l in range(222):
    for c in range(320):
      if random() < l / 222: set_pixel(c,l,(0,40,255))

def go(x,y,d):
  penup()
  goto(x,y)
  setheading(d)
  pendown()

def disque(r,a,c=BL,x=0,y=0,d=0):
  pencolor(c)
  s = 1 if d > 0 else -1
  for u in range(r):
    go(x,y+s*u,d)
    circle(u,180*a)

fond()
pensize(2)
disque(80,1)
disque(80,1,WH,d=180)
disque(40,1,y=-40,d=180)
disque(39,1,WH,x=-2,y=40)
disque(10,2,WH,y=-40,d=180)
disque(10,2,y=40)
go(-1,-80,0)
circle(80)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.