Created
October 10, 2016 22:24
-
-
Save alexeytal/3185478f939688a30b064bd4330b3cfc to your computer and use it in GitHub Desktop.
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
#!/usr/bin/python2.7 | |
import time | |
from math import sin,cos,pi,sqrt | |
from Tkinter import * | |
def rot_hand(x2,y2,rot,x1=75,y1=100): | |
xf=(x2-x1)*cos(rot)-(y2-y1)*sin(rot) | |
yf=(x2-x1)*sin(rot)+(y2-y1)*cos(rot) | |
return xf+x1,yf+y1 | |
master = Tk() | |
w = Canvas(master, width=300, height=400) | |
w.pack() | |
xr2=125 | |
yr2=175 | |
xl2=25 | |
yl2=175 | |
w.create_line(75, 100, 75, 200, width=3)#torso | |
w.create_line(75, 200, 125, 275, width=3)#right leg | |
w.create_line(75, 200, 25, 275, width=3)#left leg | |
w.create_oval(50, 50, 100, 100, width=3) #head | |
right=w.create_line(75, 100, 125, 175, width=3)#right arm | |
left=w.create_line(75, 100, 25, 175, width=3)#left arm | |
while True: | |
xr2,yr2=rot_hand(xr2,yr2,0.1) | |
xl2,yl2=rot_hand(xl2,yl2,-0.1) | |
#print(sqrt((75-xr2)**2+(100-yr2)**2)) | |
w.coords(right,75,100, xr2,yr2)#right arm | |
w.coords(left,75,100, xl2,yl2)#right arm | |
master.update() | |
time.sleep(0.05) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment