中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

利用Python完美畫出冰墩墩附完整源代碼

小云
558
2023-09-16 03:54:45
欄目: 編程語言

以下是一個利用Python畫出冰墩墩的完整源代碼:

import turtle
# 設置畫布大小和背景顏色
turtle.setup(800, 600)
turtle.bgcolor("#0077be")
# 設置畫筆屬性
turtle.penup()
turtle.speed(10)
turtle.hideturtle()
# 畫出冰墩墩的身體
turtle.goto(-100, 0)
turtle.pendown()
turtle.fillcolor("#ffffff")
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 畫出冰墩墩的臉部
turtle.penup()
turtle.goto(-50, 50)
turtle.pendown()
turtle.fillcolor("#000000")
turtle.begin_fill()
turtle.circle(15)
turtle.end_fill()
# 畫出冰墩墩的眼睛
turtle.penup()
turtle.goto(-60, 60)
turtle.pendown()
turtle.fillcolor("#ffffff")
turtle.begin_fill()
turtle.circle(5)
turtle.end_fill()
turtle.penup()
turtle.goto(-40, 60)
turtle.pendown()
turtle.fillcolor("#ffffff")
turtle.begin_fill()
turtle.circle(5)
turtle.end_fill()
# 畫出冰墩墩的嘴巴
turtle.penup()
turtle.goto(-70, 40)
turtle.pendown()
turtle.pensize(3)
turtle.right(90)
turtle.circle(70, 180)
# 畫出冰墩墩的帽子
turtle.penup()
turtle.goto(-100, 100)
turtle.pendown()
turtle.fillcolor("#ff0000")
turtle.begin_fill()
turtle.forward(200)
turtle.right(90)
turtle.forward(30)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(30)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(30)
turtle.right(90)
turtle.forward(70)
turtle.right(90)
turtle.end_fill()
# 畫出冰墩墩的圍巾
turtle.penup()
turtle.goto(-100, -70)
turtle.pendown()
turtle.pensize(10)
turtle.pencolor("#ff0000")
turtle.right(45)
turtle.forward(100)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(50)
turtle.left(135)
turtle.done()

運行該代碼,即可在turtle圖形窗口中看到畫出的冰墩墩形狀。

0
宁河县| 合阳县| 那坡县| 睢宁县| 绵阳市| 石门县| 日照市| 乳山市| 马关县| 佛冈县| 秭归县| 贵德县| 乃东县| 古丈县| 大石桥市| 泾川县| 淮安市| 吉木萨尔县| 贵德县| 政和县| 左贡县| 武川县| 来凤县| 桑日县| 普陀区| 商城县| 个旧市| 儋州市| 嘉禾县| 青岛市| 郎溪县| 颍上县| 依安县| 通化县| 伊通| 韩城市| 广安市| 内黄县| 尚义县| 武威市| 临桂县|