Python自带一套简单的图形开发工具 Turtle 小乌龟 用来画一些简单的二维图形 通过写代码来画画
绘制一个五环图
import turtle
turtle.speed(10)
#左上角蓝色的环
turtle.color("blue")
turtle.pensize(10)
turtle.penup()
turtle.goto(-110,-25)
turtle.pendown()
turtle.circle(45)
#上中黑色的环
turtle.color("black")
turtle.pensize(10)
turtle.penup()
turtle.goto(0,-25)
turtle.pendown()
turtle.circle(45)
#右上红色的环
turtle.color("red")
turtle.pensize(10)
turtle.penup()
turtle.goto(110,-25)
turtle.pendown()
turtle.circle(45)
#左下黄色的环
turtle.color("yellow")
turtle.pensize(10)
turtle.penup()
turtle.goto(-55,-75)
turtle.pendown()
turtle.circle(45)
#右下绿色的环
turtle.color("green")
turtle.pensize(10)
turtle.penup()
turtle.goto(55,-75)
turtle.pendown()
turtle.circle(45)
turtle.done()
import turtle
turtle.goto(400, 0)
turtle.goto(400, 200)
turtle.goto(0, 200)
turtle.goto(0, 0)
turtle.penup()
turtle.goto(300, 100)
turtle.pendown()
turtle.goto(300, -100)
turtle.goto(-100, -100)
turtle.goto(-100, 100)
turtle.goto(300, 100)
turtle.goto(400, 200)
turtle.penup()
turtle.goto(300, -100)
turtle.pendown()
turtle.goto(400, 0)
turtle.penup()
turtle.goto(-100, -100)
turtle.pendown()
turtle.goto(0, 0)
turtle.penup()
turtle.goto(-100, 100)
turtle.pendown()
turtle.goto(0, 200)
turtle.done()
# 绘制填充图形
import turtle
turtle.speed(10)
turtle.pensize(3)
turtle.penup()
turtle.goto(-200,-50)
turtle.pendown()
turtle.begin_fill()
turtle.color("red")
turtle.circle(40,steps=3)
turtle.end_fill()
turtle.penup()
turtle.goto(-100,-50)
turtle.pendown()
turtle.begin_fill()
turtle.color("blue")
turtle.circle(40,steps=4)
turtle.end_fill()
turtle.done()