python——海龟绘图

import turtle
turtle.forward(150)
turtle.right(25)

from turtle import *
color('red', 'yellow')
begin_fill()
while True:
    forward(200)
    left(170)
    if abs(pos()) < 1:
        break
end_fill()
done()

from turtle import *

color = ['red','black','yellow','blue','green','purple','orange']
for i in range(0,300,10):
                pencolor(color[i%7])
                #pencolor('red')
                fd(i)
                lt(90)

from turtle import *

pensize(5)
goto(0,200)
color = ['red','black','yellow','blue','green','purple','orange']
for i in range(0,150,15):
                pensize(15)
                pencolor(color[i%7])
                #pencolor('red')
                circle(i,extent=180)
                
from turtle import *

args = {(-126,162):65,(-58,55):65,(-58,-48):65,(-126,-162):65,(-300,50):120}
bgcolor('red')
setup(800,500)
def star(tuples,size):
                up()
                color('yellow','yellow')
                goto(tuples[0],tuples[1])
                begin_fill()
                for i in range(5):
                                fd(size)
                                rt(144)
                end_fill()
                up()
                goto(0,0)
if __name__ == '__main__':
                for key,value in args.items():
                                star(key,value)
                hideturtle()

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当然可以!使用Python海龟绘图库可以让我们绘制出皮卡丘的图像。下面是一个简单的示例代码: ```python import turtle as t # 设置画布大小和背景色 t.setup(800, 600) t.bgcolor('yellow') # 绘制皮卡丘的头部 t.penup() t.goto(-100, 100) t.pendown() t.fillcolor('yellow') t.begin_fill() t.circle(100) t.end_fill() # 绘制皮卡丘的眼睛 t.penup() t.goto(-60, 120) t.pendown() t.fillcolor('white') t.begin_fill() t.circle(20) t.end_fill() t.penup() t.goto(-40, 120) t.pendown() t.fillcolor('black') t.begin_fill() t.circle(10) t.end_fill() t.penup() t.goto(-140, 120) t.pendown() t.fillcolor('white') t.begin_fill() t.circle(20) t.end_fill() t.penup() t.goto(-120, 120) t.pendown() t.fillcolor('black') t.begin_fill() t.circle(10) t.end_fill() # 绘制皮卡丘的嘴巴 t.penup() t.goto(-80, 30) t.pendown() t.setheading(-60) t.circle(80, 120) t.fillcolor('black') t.begin_fill() t.circle(80, 120) t.setheading(0) t.circle(80, 120) t.end_fill() # 绘制皮卡丘的脚 t.penup() t.goto(-70, -70) t.pendown() t.setheading(-30) t.forward(80) t.setheading(0) t.forward(40) t.setheading(90) t.fillcolor('black') t.begin_fill() t.circle(40, 180) t.end_fill() t.setheading(180) t.forward(40) t.setheading(-90) t.circle(40, 180) t.setheading(-60) t.forward(80) # 绘制皮卡丘的手臂 t.penup() t.goto(30, -70) t.pendown() t.setheading(-30) t.forward(80) t.setheading(0) t.forward(40) t.setheading(90) t.fillcolor('black') t.begin_fill() t.circle(40, 180) t.end_fill() t.setheading(180) t.forward(40) t.setheading(-90) t.circle(40, 180) t.setheading(-60) t.forward(80) # 隐藏画笔 t.hideturtle() # 完成绘制 t.done() ``` 运行以上代码,即可在窗口中看到绘制出的皮卡丘图像。你也可以根据需要调整代码中的坐标和尺寸来绘制更精确的图像。希望对你有所帮助!

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值