gbk.py

Created by schraf

Created on April 13, 2024

1.15 KB

Ghee Beom Kim


import turtle
from math import sqrt
from kandinsky import fill_rect

fill_rect(0,0,320,222,(196,207,209))
t = turtle

t.speed(0)
r3 = sqrt(3)
D = 8

ob1 = 0,2,90,r3,60,r3,90,1,120,1,-90,r3/2,-90,1,90,r3/2
ob2 = 0,1,-120,1,-90,2*r3,-90,1,-60,2
ob3 = 0,3,-60,3,-90,r3/2,-90,1,90,r3/2,90,1,-120,1,-90,r3,60,r3
ob4 = 0,2,90,r3,60,r3,90,1

def go(x,y,a):
  t.penup()
  t.setheading(a)
  t.goto(x,y)
  t.fd(D*r3)
  t.right(90)
  t.fd(2*D)
  t.setheading(a + 90)  

def aff(o,n):
  t.pendown()
  for i in range(0,len(o),2):
    t.left(o[i])
    if n == 3 and i == 10:
      (xp, yp) = t.position()
      ap = t.heading()
    t.fd(D*o[i+1])
  if n == 3:
    t.penup()
    t.goto(xp, yp)
    t.setheading(ap)

def tiles(x,y,a):    
  go(x,y,a)    
  aff(ob1,1)
  go(x,y,a) 
  aff(ob2,2)
  go(x,y,a) 
  aff(ob3,3)
  aff(ob4,1)

def shape(u,v):  
  for i in range(6):  
    t.setheading(60 * i)
    t.penup()
    t.goto(u, v)
    t.fd(4 * r3 * D)
    (x, y) = t.position()
    for a in range(3):  
      tiles(x,y,60 * i + 120 * a -60)

for l in range(3):
  for c in range(3):
    shape(-6 * D * (l % 2) * r3 + 12 * D * c  * r3 - 100, (36 - l * 18) * D - 80) 

t.hideturtle()

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 <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.