图片一
py
import turtle
t = turtle.Turtle()
t.goto(-100,0)
t.pensize(5) #设置外花边的大小
t.color('red', 'yellow') #参数一是笔画颜色,参数二是填充颜色
t.begin_fill()
for i in range(0, 20):
t.forward(200)
t.left(170)
t.end_fill()
t.done()
图片二 :画一个狮子
绘制过程
效果如下 :
然后绘制 眼睛
和 鼻子
:
补全其他部分 :
最后绘制三角形组合的鬓毛即可。
结果与代码
py
import turtle
# 画圆形, 颜色为 color, 圆心为 (x, y), 半径为 radius
def draw_circle(color, x, y, radius):
turtle.penup() # 提笔,不画线
turtle.goto(x, y - radius)
turtle.pendown() # 落笔,开始画线
turtle.color(color)
turtle.begin_fill()
turtle.circle(radius)
turtle.end_fill()
# """ 画鬃毛 """
def draw_mane():
turtle.penup()
turtle.goto(0, -120)
turtle.pendown()
turtle.color("orange")
for _ in range(36):
turtle.begin_fill()
turtle.circle(40, steps=3) # 三角形鬃毛
turtle.end_fill()
turtle.right(10)
def draw_lion():
turtle.speed(10) # value 可以是 0 到 10 之间的整数, 10 是最快
turtle.bgcolor("white")
# 画鬃毛
draw_mane()
# 画头部
draw_circle("goldenrod", 0, -50, 100)
# 画眼睛
draw_circle("white", -40, 30, 20)
draw_circle("white", 40, 30, 20)
draw_circle("black", -35, 35, 8)
draw_circle("black", 35, 35, 8)
# 画鼻子
draw_circle("black", 0, 0, 15)
# 画嘴巴(微笑曲线)
turtle.penup()
turtle.goto(-20, -20)
turtle.pendown()
turtle.width(3)
turtle.setheading(-60) # setheading(angle) 直接将乌龟的方向调整到指定的角度,而不是相对旋转。
turtle.circle(20, 120)
# 画耳朵
draw_circle("goldenrod", -60, 60, 30)
draw_circle("goldenrod", 110, 60, 30)
# 画耳朵内部
draw_circle("peru", -70, 65, 15)
draw_circle("peru", 100, 65, 15)
turtle.hideturtle()
draw_lion()
turtle.done()