Skip to content

Instantly share code, notes, and snippets.

@cosminonea
Created June 6, 2015 09:24
Show Gist options
  • Save cosminonea/4d9e41d4aa5758986669 to your computer and use it in GitHub Desktop.
Save cosminonea/4d9e41d4aa5758986669 to your computer and use it in GitHub Desktop.
drawing a Sierpinsky Gasket
import Tkinter as tk
root = tk.Tk()
root.geometry("1000x1000")
root.title("Drawing lines to a canvas")
cv = tk.Canvas(root,height="1000",width="1000",bg="white")
cv.configure(scrollregion=cv.bbox('all'))
cv.pack()
for y in range(255):
for x in range(y):
if x & (y - x):
xcoord = x + 158 - 0.5*y
ycoord = y + 30
cv.create_line(xcoord,ycoord,xcoord + 1, ycoord + 1)
for y in range(255):
for x in range(255,511):
if x & y:
xcoord = x + 30
ycoord = y + 30
cv.create_line(xcoord,ycoord,xcoord + 1, ycoord + 1)
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment