turtle之绘制美国队长的盾牌

turtle之绘制美国队长的盾牌

第一步:导入库turtle
import  turtle as t
第二步,绘制盾牌的圆:
def circle(x,y,r,color):
  t.goto(x,y)
  t.color(color,color)
  t.begin_fill()
  t.circle(r)
  t.end_fill()
circle(0,-200,200,'red')
circle(0,-150,150,'white')
circle(0,-100,100,'red')
circle(0,-50,50,'blue')
第三步:绘制盾牌中间的五角星:
def wjx(x,y,p,color):
    t.goto(x,y)
    t.color(color,color)
    t.begin_fill()
    for i in range(5):
            t.forward(p)
            t.right(144)
    t.end_fill()
最后一步:调用定义五角星的函数:
if __name__=="__main__":
  wjx(-48,15,93,'white')
  t.done()

完整代码如下:

import  turtle as t
t.speed(0)#一步生成图像,不用慢慢画
def circle(x,y,r,color):
  t.goto(x,y)
  t.color(color,color)
  t.begin_fill()
  t.circle(r)
  t.end_fill()
circle(0,-200,200,'red')
circle(0,-150,150,'white')
circle(0,-100,100,'red')
circle(0,-50,50,'blue')


def wjx(x,y,p,color):
    t.goto(x,y)
    t.color(color,color)
    t.begin_fill()
    for i in range(5):
            t.forward(p)
            t.right(144)
    t.end_fill()

if __name__=="__main__":
  wjx(-48,15,93,'white')
  t.done()#使画布一直停留,不会画完就消失

效果如图:

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
可以使用Python中的turtle库来画美国队长盾牌,具体步骤如下: 1. 导入turtle库: ```python import turtle ``` 2. 创建turtle窗口: ```python window = turtle.Screen() ``` 3. 创建turtle对象并设置画笔颜色、粗细等属性: ```python pen = turtle.Turtle() pen.pensize(5) pen.color("red", "blue") ``` 4. 画圆并填充颜色: ```python pen.begin_fill() pen.circle(100) pen.end_fill() ``` 5. 画五角星: ```python pen.penup() pen.goto(0, 170) pen.pendown() for i in range(5): pen.forward(60) pen.right(144) pen.penup() pen.goto(0, 0) pen.pendown() for i in range(5): pen.forward(60) pen.left(144) ``` 6. 添加美国队长盾牌的红色和白色条纹: ```python pen.penup() pen.goto(-120, 80) pen.pendown() pen.color("red") pen.begin_fill() pen.forward(240) pen.right(90) pen.forward(30) pen.right(90) pen.forward(240) pen.right(90) pen.forward(30) pen.end_fill() pen.penup() pen.goto(-120, 50) pen.pendown() pen.color("white") pen.begin_fill() pen.forward(240) pen.right(90) pen.forward(30) pen.right(90) pen.forward(240) pen.right(90) pen.forward(30) pen.end_fill() ``` 7. 完成绘制: ```python window.exitonclick() ``` 完整代码如下: ```python import turtle window = turtle.Screen() pen = turtle.Turtle() pen.pensize(5) pen.color("red", "blue") pen.begin_fill() pen.circle(100) pen.end_fill() pen.penup() pen.goto(0, 170) pen.pendown() for i in range(5): pen.forward(60) pen.right(144) pen.penup() pen.goto(0, 0) pen.pendown() for i in range(5): pen.forward(60) pen.left(144) pen.penup() pen.goto(-120, 80) pen.pendown() pen.color("red") pen.begin_fill() pen.forward(240) pen.right(90) pen.forward(30) pen.right(90) pen.forward(240) pen.right(90) pen.forward(30) pen.end_fill() pen.penup() pen.goto(-120, 50) pen.pendown() pen.color("white") pen.begin_fill() pen.forward(240) pen.right(90) pen.forward(30) pen.right(90) pen.forward(240) pen.right(90) pen.forward(30) pen.end_fill() window.exitonclick() ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Deng872347348

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值