Python
用turtle画出党徽
import turtle as t
def go(x,y): # 到达指定地方
t.pu()
t.goto(x,y)
t.pd()
def upfd(c): # 提笔前进函数
t.pu()
t.fd(c)
t.pd()
def dh(a,x,y,ys="yellow"): # 参数a是基础大小的倍数,参数(x,y)是党徽的位置,ys党徽的颜色,默认黄色
# 锤子
t.speed(0)
t.color(ys)
t.begin_fill()
go(x,y)
t.seth(-45)
t.fd(4.3*a)
t.rt(90)
t.fd(5*a)
t.lt(90)
t.fd(24.8*a)
t.rt(90)
t.fd(5.7*a)
t.rt(90)
t.fd(24.8*a)
t.lt(90)
t.fd(5*a)
t.rt(90)
t.fd(7.1*a)
t.rt(90)
t.fd(11.3*a)
t.seth(0)
t.fd(3.5*a)
t.goto(x,y)
t.end_fill()
t.seth(90)
upfd(4*a)
t.seth(0)
# 镰刀
t.begin_fill()
t.circle(-16*a,180)
t.circle(-18*a,56.31)
t.seth(45)
t.fd(3.53*a)
t.rt(90)
t.circle(16.6*a,46.22)
t.circle(11.1*a,90)
t.circle(16.6*a,68.8)
t.end_fill()
t.seth(-90)
upfd(32*a)
t.rt(90)
upfd(13.5*a)
t.seth(0)
t.begin_fill()
# 镰刀手把
t.circle(2.8*a)
t.end_fill()
t.ht()
import turtle
turtle.fillcolor("red")
turtle.pencolor("red")
turtle.up()
turtle.goto(-300, 300)
turtle.down()
turtle.begin_fill()
for i in range(2):
turtle.forward(600)
turtle.right(90)
turtle.forward(400)
turtle.right(90)
turtle.end_fill()
turtle.fillcolor("yellow")
turtle.pencolor("yellow")
turtle.up()
turtle.goto(10, 220)
turtle.seth(225)
turtle.down()
turtle.begin_fill()
turtle.fd(125)
turtle.right(90)
turtle.fd(50)
turtle.right(90)
turtle.fd(100)
turtle.right(90)
turtle.circle(25, 90)
turtle.end_fill()
turtle.up()
turtle.goto(-40, 190)
turtle.seth(-45)
turtle.down()
turtle.begin_fill()
for i in range(2):
turtle.forward(200)
turtle.right(90)
turtle.forward(30)
turtle.right(90)
turtle.end_fill()
turtle.up()
turtle.goto(-100, 100)
turtle.seth(-50)
turtle.down()
turtle.begin_fill()
turtle.circle(100, 180)
turtle.fd(20)
turtle.right(157)
turtle.circle(-115, 190)
turtle.left(90)
turtle.fd(20)
turtle.right(90)
turtle.fd(20)
turtle.right(90)
turtle.fd(20)
turtle.left(80)
turtle.fd(30)
turtle.end_fill()
turtle.up()
turtle.goto(-90, 50)
turtle.down()
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.hideturtle()
# 维持面板
turtle.done()
如果觉得答案还行,记得采纳哟!
头皮发麻,上次我们用cad画都差点没画出来。我只能说加油