荔枝葡萄 发表于 2020-11-29 15:27:31

用Canvas绘制哆啦A梦

from tkinter import *

root = Tk()

#画板
paint = Canvas(root, width=600, height=600, background="white")
paint.pack()

#头
paint.create_oval(175, 100, 425, 350, fill="#1E90FF")

#脸
paint.create_oval(200, 150, 400, 350, fill="white")

#眼睛
paint.create_oval(250, 120, 300, 180, fill="white")
paint.create_oval(300, 120, 350, 180, fill="white")
paint.create_oval(280, 140, 295, 160, fill="black")
paint.create_oval(305, 140, 320, 160, fill="black")
paint.create_oval(285, 145, 290, 155, fill="white")
paint.create_oval(310, 145, 315, 155, fill="white")

#鼻子
paint.create_oval(290, 167, 310, 189, fill="red")
paint.create_line(300, 190, 300, 270, fill="black")

#嘴巴
paint.create_arc(240, 230, 360, 270, style=ARC, extent=-180)

#右边胡子
paint.create_line(320, 210, 380, 185)
paint.create_line(320, 220, 385, 220)
paint.create_line(320, 230, 380, 250)

#左边胡子
paint.create_line(280, 210, 220, 185)
paint.create_line(215, 220, 280, 220)
paint.create_line(220, 250, 280, 230)

#身体
paint.create_rectangle(200, 300, 400, 485, fill="#1E90FF")

#肚子
paint.create_oval(230, 285, 370, 425, fill="white")
paint.create_arc(230, 285, 370, 425, outline="white", width=2,
               start=54, extent=73, style=ARC)

#项圈
paint.create_line(200, 300, 400, 300, capstyle=ROUND, width=15, fill="red")

#铃铛
paint.create_oval(285, 300, 317, 332, fill="yellow")
paint.create_line(286, 312, 316, 312, capstyle=ROUND)
paint.create_line(285, 316, 316, 316, capstyle=ROUND)
paint.create_oval(295, 320, 305, 328, fill="red")
paint.create_line(300, 327, 300, 332)

#口袋
paint.create_arc(246, 300, 354, 410, extent=-180)

#脚
paint.create_arc(280, 465, 322, 504, extent=180,fill="white", outline="white")
paint.create_oval(190, 470, 290, 500, fill="white")
paint.create_oval(310, 470, 410, 500, fill="white")

#左手
lpoints = [200, 306,
         125, 365,
         145, 395,
         200, 372]
paint.create_polygon(lpoints, fill="#1E90FF")
paint.create_oval(114, 356, 160, 402, fill="white")

#右手
rpoints = [401, 306,
         477, 365,
         445, 395,
         401, 372]
paint.create_polygon(rpoints, fill="#1E90FF")
paint.create_oval(440, 355, 487, 402, fill="white")

mainloop()


截图:

python_zbl 发表于 2020-11-29 22:42:33

杨文龙 发表于 2020-12-1 14:36:55

哈哈,有意思

彼爵i 发表于 2020-12-2 12:15:11

{:10_254:}

thon怪 发表于 2020-12-5 16:52:17

{:10_279:}

青松100 发表于 2020-12-5 16:58:20

太厉害了。这个算法是咋搞出来的?

荔枝葡萄 发表于 2020-12-7 14:12:45

青松100 发表于 2020-12-5 16:58
太厉害了。这个算法是咋搞出来的?

用python的Canvas(画布)弄的

青松100 发表于 2020-12-7 14:15:12

荔枝葡萄 发表于 2020-12-7 14:12
用python的Canvas(画布)弄的

谢谢指导

满不懂 发表于 2020-12-13 22:12:52

新人报到进来看看
页: [1]
查看完整版本: 用Canvas绘制哆啦A梦