春联
点击查看代码
import turtle
t = turtle
t.showturtle()
t.penup()
t.goto(-150,150)
t.pendown()t.color('black', 'red')
t.begin_fill()
for i in range(2):t.forward(50)t.right(90)t.forward(400)t.right(90)
t.end_fill()t.penup()
t.goto(100, 150)
t.pendown()t.begin_fill()
for i in range(2):t.forward(50)t.right(90)t.forward(400)t.right(90)
t.end_fill()t.penup()
t.goto(-100, 250)
t.pendown()t.color('black', 'red')
t.begin_fill()
for i in range(2):t.forward(200)t.right(90)t.forward(50)t.right(90)
t.end_fill()t.penup()
t.goto(-150, -250)
t.pendown()
#上联:春临大地百花艳
#下联:节至人间万象新
#横批:万事如意
t.write("春\n临\n大\n地\n百\n花\n艳", align = "left", font = ("华文行楷",40))t.penup()
t.goto(100, -250)
t.pendown()
t.write("节\n至\n人\n间\n万\n象\n新", align="left", font=("华文行楷", 40))t.penup()
t.goto(-100, 200)
t.pendown()
t.write("万事如意", align="left", font=("华文行楷", 36))
t.hideturtle()
t.done()
新年贺卡
点击查看代码
import turtle
t = turtlet.color('gold')
t.penup()
t.goto(80,0)
t.pendown()
t.write("万\n事\n大\n吉",font=("华文行楷",45,"normal"))
t.penup()
t.goto(0,0)
t.pendown()
t.write("新\n年\n快\n乐",font=("华文行楷",45,"normal"))t.color("black")
t.penup()
t.goto(-120,110)
t.pendown()
t.write("新\n年\n贺\n卡", font=("华文行楷", 20, "normal"))t.penup()
t.goto(-130,0)
t.pendown()
t.color("red")
t.begin_fill()
for i in range(4):t.forward(55)t.left(90)
t.end_fill()t.pensize(2)
t.color('white')
t.write('自制\n印章', font=("华文行楷", 20, "normal"))t.done()
简易版红旗绘制
点击查看代码
import turtle def move(x,y):t.penup()t.goto(x,y)t.pendown()def star(x):t.color('yellow')t.begin_fill()for i in range(5):t.forward(x)t.right(144)t.end_fill()t = turtle
t.setup(600, 400,0,0)
t.bgcolor('red')move(-260,120)
star(120)
move(-120,160)
star(40)
move(-80,120)
star(40)
move(-80,60)
star(40)
move(-120,20)
star(40)t.done()
简易版奥运五环
点击查看代码
import turtle
t = turtledef drawCircle(x,y,r,pensize,color):t.penup() #抬笔t.goto(x,y) #移动位置t.pendown() #落笔t.pensize(pensize) #设置画笔粗细t.color(color) #设置画笔颜色t.circle(-r) #顺时针画圆drawCircle(-240,200,100,20,'blue')
drawCircle( 0,200,100,20,'black')
drawCircle( 240,200,100,20,'red')
drawCircle(-120,100,100,20,'orange')
drawCircle( 120,100,100,20,'green')t.done()
补充版奥运五环
点击查看代码
import turtle
t = turtledef drawCircle(x,y,r,pensize,color):t.penup() #抬笔t.goto(x,y) #移动位置t.pendown() #落笔t.pensize(pensize+6) # 设置画笔粗细t.pencolor("white") # 设置画笔颜色t.circle(-r) # 顺时针画圆t.pensize(pensize) # 设置画笔粗细t.color(color) #设置画笔颜色t.circle(-r) #顺时针画圆def drawnest(x, y, r, pensize, color, extent,offset):t.setheading(0)t.penup() # 抬笔t.goto(x, y) # 移动位置t.circle(-r, 5) # 顺时针画圆t.circle(-r, offset)t.pendown() # 落笔t.pensize(pensize+12) # 设置画笔粗细t.pencolor("white") # 设置画笔颜色t.circle(-r, extent-10) # 顺时针画圆t.setheading(0)t.penup() # 抬笔t.goto(x, y) # 移动位置t.circle(-r, offset)t.pendown() # 落笔t.pensize(pensize) # 设置画笔粗细t.color(color) # 设置画笔颜色t.circle(-r,extent) # 顺时针画圆drawCircle(-240,200,100,20,'blue')
drawCircle( 0,200,100,20,'black')
drawCircle( 240,200,100,20,'red')
drawCircle(-120,100,100,20,'orange')
drawCircle( 120,100,100,20,'green')drawnest(-240, 200, 100, 20, 'blue',60,60)
drawnest(0, 200, 100, 20, 'black', 60,60)
drawnest(0, 200, 100, 20, 'black', 60, 180)
drawnest(240, 200, 100, 20, 'red', 60, 180)t.done()
多边形
点击查看代码
import turtle
t = turtlea = int(t.textinput("输入", "输入多边形的个数:"))
b = int(t.textinput("输入", "输入多边形的边数:"))
c = int(t.textinput("输入", "输入多边形的边长:"))
t.color('red')
for i in range(a):for j in range(b):t.forward(c)t.right(360/b)t.right(360/a)
t.done()
多边形
点击查看代码
import turtle
t = turtlea = 6
b = 6
c = 6
d = 100
for i in range(a):for j in range(b):for k in range(c):t.forward(20)t.right(360/c)t.forward(100)t.right(360/b)t.right(360/a)
t.done()