Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- import math
- import copy
- from random import randrange as rnd, choice
- root = Tk()
- root.geometry('600x600')
- canv = Canvas(root, bg = 'white')
- canv.pack(fill = BOTH, expand = 1)
- class Point():
- def __init__(self,x,y):
- self.x = x
- self.y = y
- def getXY(p1,p2,t):
- x = p1.x + (p2.x-p1.x)*t
- y = p1.y + (p2.y-p1.y)*t
- return Point(x,y)
- t = 1/5
- points = []
- points.append(Point(100,100))
- points.append(Point(300,100))
- points.append(Point(400,300))
- points.append(Point(200,500))
- points.append(Point(100,200))
- n = 30
- for i in range(n):
- new_points = []
- for i in range(len(points)):
- p1 = points[i-1]
- p2 = points[i]
- canv.create_line(p1.x,p1.y,p2.x,p2.y)
- p = getXY(p1,p2,t)
- new_points.append(p)
- points = copy.deepcopy(new_points)
- mainloop()
Advertisement
Add Comment
Please, Sign In to add comment