Python是一種強大的編程語言,可以用它來制作各種有趣的圖形。這篇文章將向你展示如何用Python繪制一個可愛的草莓熊。
import turtle
# 設置畫布
turtle.setup(600, 600)
turtle.speed(3)
# 畫草莓
turtle.penup()
turtle.goto(-50, 250)
turtle.pendown()
turtle.color("#ff6699")
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
# 畫草莓的臉
turtle.penup()
turtle.goto(-35, 190)
turtle.pendown()
turtle.color("white")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
# 畫草莓的耳朵
turtle.penup()
turtle.goto(-65, 240)
turtle.pendown()
turtle.color("#ff6699")
turtle.begin_fill()
turtle.setheading(60)
turtle.circle(30, 120)
turtle.setheading(-60)
turtle.circle(30, 120)
turtle.end_fill()
# 畫草莓的眼睛
turtle.penup()
turtle.goto(-20, 210)
turtle.pendown()
turtle.color("black")
turtle.dot(15)
turtle.penup()
turtle.goto(-20, 210)
turtle.pendown()
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 畫草莓的耳眼
turtle.penup()
turtle.goto(-70, 240)
turtle.pendown()
turtle.color("black")
turtle.dot(10)
turtle.penup()
turtle.goto(-70, 240)
turtle.pendown()
turtle.begin_fill()
turtle.circle(5)
turtle.end_fill()
# 畫草莓的嘴巴
turtle.penup()
turtle.goto(-40, 180)
turtle.pendown()
turtle.setheading(270)
turtle.circle(20, 180)
完成以上代碼后,你就可以看到一個可愛的草莓熊在你的畫布上了!如果你想讓他更加可愛,你可以繼續(xù)為他添加其他部分,比如身體和胳膊。