|
发表于 2019-7-13 14:49:46
|
显示全部楼层
本帖最后由 cheadache 于 2019-7-13 15:01 编辑
from tkinter import *
root = Tk()
c = Canvas(root, width=500, height=600, background='white')
c.pack()
grid_x = c.create_line(-250, 0, 250, 0, dash=(10, 10), fill='gray')
grid_y = c.create_line(0, -300, 0, 300, dash=(10, 10), fill='gray')
#所有都在原点绘图,方便对称计算,最后再移动动画面中央
#头
head_01 = c.create_oval(100, 103, -100, -103, fill='DeepSkyBlue')
c.move(head_01, 0, -70)
head_02 = c.create_oval(85, 88, -85, -88, fill='white')
c.move(head_02, 0, -50)
head_eye01 = c.create_oval(20, 23, -20, -23, fill='white')
head_eye02 = c.create_oval(20, 23, -20, -23, fill='white')
c.move(head_eye01, -20, -135)
c.move(head_eye02, 20, -135)
head_eye_hole01 = c.create_oval(6, 8, -6, -8, fill='black')
head_eye_hole02 = c.create_oval(6, 8, -6, -8, fill='black')
c.move(head_eye_hole01, -10, -135)
c.move(head_eye_hole02, 10, -135)
head_eye_flash01 = c.create_oval(2, 5, -2, -5, fill='white')
head_eye_flash02 = c.create_oval(2, 5, -2, -5, fill='white')
c.move(head_eye_flash01, -10, -135)
c.move(head_eye_flash02, 10, -135)
head_nose = c.create_oval(8, 8, -8, -8, fill='red')
c.move(head_nose, 0, -115)
head_mouse01 = c.create_arc(50, 15, -50, -15, style=ARC, extent=-180)
c.move(head_mouse01, 0, -50)
head_mouse02 = c.create_line(0, -35, 0, -107)
head_beard01 = c.create_line(-20, -90, -60, -100)
head_beard02 = c.create_line(20, -90, 60, -100)
head_beard03 = c.create_line(-20, -80, -65, -80)
head_beard04 = c.create_line(20, -80, 65, -80)
head_beard05 = c.create_line(-20, -70, -60, -60)
head_beard06 = c.create_line(20, -70, 60, -60)
#手和胳膊
body_arm_left = c.create_polygon(-80, 0, -80, 40, -125, 50, -135, 35, fill='deepskyblue', outline='black')
body_arm_right = c.create_polygon(80, 0, 80, 40, 125, 50, 135, 35, fill='deepskyblue', outline='black')
body_hand_right = c.create_oval(20, 20, -20, -20, fill='white')
c.move(body_hand_right, 130, 42.5)
body_hand_right = c.create_oval(20, 20, -20, -20, fill='white')
c.move(body_hand_right, -130, 42.5)
body_main = c.create_rectangle(-80, -10, 80, 110, fill='deepskyblue')
body_tummy = c.create_arc(-60, -60, 60, 60, fill='white', extent=270, start=135, style=CHORD)
c.move(body_tummy, 0, 30)
body_bag = c.create_arc(-40, -40, 40, 40, fill='white', extent=-180)
c.move(body_bag, 0, 30)
#腿
cover = c.create_arc(20, 20, -20, -20, fill='white', extent=180)
c.move(cover, 0, 115)
cover02 = c.create_arc(20, 20, -20, -20, fill='white', extent=-180, outline='')
c.move(cover02, 0, 110)
foot_left = c.create_oval(-40, -20, 40, 20, fill='white')
c.move(foot_left, -50, 115)
foot_right = c.create_oval(-40, -20, 40, 20, fill='white')
c.move(foot_right, 50, 115)
#铃铛
bell_07 = c.create_line(-80, -10, 80, -10, fill='black', width=17, capstyle='round')
bell_05 = c.create_line(-80, -10, 80, -10, fill='red', width=15, capstyle='round')
bell_01 = c.create_oval(15, 15, -15, -15, fill='yellow')
bell_02 = c.create_line(-12, -5, 12, -5, fill='black', width=7, capstyle='round')
bell_03 = c.create_line(-12, -5, 12, -5, fill='yellow', width=5, capstyle='round')
bell_04 = c.create_oval(4, 4, -4, -4, fill='red')
c.move(bell_04, 0, 6)
bell_06 = c.create_line(0, 8, 0, 15)
#移动动画面中央
for each in c.find_all():
c.move(each, 250, 300)
mainloop() |
|