Created
June 6, 2015 09:24
-
-
Save cosminonea/4d9e41d4aa5758986669 to your computer and use it in GitHub Desktop.
drawing a Sierpinsky Gasket
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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