python几何拼图鱼儿fish

python几何拼图鱼儿fish

python几何绘图拼图鱼

python几何绘图拼图鱼
发挥想像力,Python也能做这样简单又有趣的拼图类画儿。

"""
   几何拼图鱼.py
"""
import turtle

# 绘制三角形,头部上面的三角形
turtle.up()
turtle.goto(-250,5)
turtle.pendown()
turtle.color('red')
turtle.begin_fill()
turtle.fd(200)
turtle.left(90)
turtle.fd(200)
turtle.goto(-250,5)
turtle.end_fill()


# 绘制三角形,头部下面的三角形
turtle.penup()
turtle.setheading(0)
turtle.goto(-250,-5)
turtle.down()
turtle.color("#55ff55")
turtle.begin_fill()
turtle.fd(200)
turtle.right(90)
turtle.fd(200)
turtle.goto(-250,-5)
turtle.end_fill()

# 绘制身体(正方形)
turtle.up()
turtle.goto(-40,50)
turtle.down()
turtle.seth(0)
turtle.color('blue')
turtle.begin_fill()
for _ in range(4):
    turtle.fd(100)
    turtle.right(90)
turtle.end_fill()


# 绘制身体(三角形_上)
turtle.up()
turtle.goto(-40,60)
turtle.down()
turtle.color('yellow')
turtle.begin_fill()
turtle.fd(100)
turtle.left(135)
turtle.fd(144)
turtle.left(135)
turtle.fd(100)
turtle.end_fill()

# 绘制身体(扇形-上)
turtle.up()
turtle.color("#55ff55")
turtle.begin_fill()
turtle.goto(35,100)
turtle.down()
turtle.seth(45)
turtle.fd(110)
turtle.left(90)
turtle.circle(110,90)
turtle.goto(35,100)
turtle.end_fill()

# 绘制身体(三角形-下)
turtle.penup()
turtle.goto(-40,-60)
turtle.pendown()
turtle.setheading(0)
turtle.color('red')
turtle.begin_fill()
turtle.fd(100)
turtle.right(135)
turtle.fd(144)
turtle.right(135)
turtle.fd(100)
turtle.end_fill()

# 绘制身体(扇形-下)
turtle.penup()
turtle.color('green')
turtle.goto(35,-100)
turtle.pendown()
turtle.setheading(-45)
turtle.begin_fill()
turtle.forward(110)
turtle.left(90)
turtle.circle(110,-90)
turtle.end_fill()

# 绘制尾巴
turtle.penup()
turtle.color('yellow')
turtle.goto(170,0)
turtle.down()
turtle.dot(200)
turtle.goto(250,0)
turtle.dot(200,'white')

# 文字
turtle.penup()
turtle.pencolor('green')
turtle.goto(250,-250)
turtle.write("FISH",font=("Airal",20))
turtle.hideturtle()
turtle.done()
李兴球

李兴球的博客是Python创意编程原创博客