python的logo图_Turtle绘画Python-logo

由于初次接触并使用python的turtle库绘图,所以绘图没什么算法,只是按照自己的想法一笔一划绘制自己想要的图案。有兴趣的朋友可以自己试着绘画自己喜欢的人或物。

绘图平台:www.python123.io;画布大小:1280*720。

利用函数绘制每个字母,然后调整每个字母的位置以达到绘制一张大图的目的。

代码:

#Python--logo

import turtle

#定义函数,绘制字母p

def chr_p(x,y):

turtle.pensize(20)

turtle.color(255,97,0)

turtle.pu()

turtle.goto(x,y)

turtle.pd()

turtle.seth(270)

turtle.fd(150)

turtle.pu()

turtle.goto(x,y)

turtle.pd()

turtle.left(90)

turtle.fd(60)

turtle.circle(-20,180)

turtle.fd(60)

#end p()

#定义函数,绘制字母y

def chr_y(x,y):

turtle.pensize(10)

turtle.color(0,255,0)

turtle.pu()

turtle.goto(x,y)

turtle.pd()

turtle.seth(270)

turtle.fd(40)

turtle.circle(25,180)

turtle.fd(40)

turtle.bk(80)

turtle.seth(270)

a=0.2

for i in range(60):

if 0<=i<20 or 40<=i<60:

a=a+0.08

turtle.rt(2)

turtle.fd(a)

else:

a=a-0.08

turtle.rt(2)

turtle.fd(a)

#end y()

#定义函数,绘制字母t

def chr_t(x,y):

turtle.pensize(10)

turtle.color(56,94,15)

turtle.pu()

turtle.goto(x,y)

turtle.pd()

turtle.seth(0)

turtle.fd(60)

turtle.pu()

turtle.goto(x+30,y+20)

turtle.pd()

turtle.right(90)

turtle.fd(100)

turtle.circle(25,90)

#turtle.fd(10)

#end t()

#定义函数,绘制字母h

def chr_h(x,y):

turtle.pensize(10)

turtle.color(176,224,230)

turtle.pu()

turtle.goto(x,y)

turtle.pd()

turtle.seth(270)

turtle.fd(150)

turtle.bk(60)

turtle.left(90)

turtle.fd(30)

turtle.circle(-20,90)

turtle.fd(40)

#end h()

#定义函数,绘制字母o

def chr_o(x,y):

turtle.pensize(10)

turtle.color(0,255,127)

turtle.pu()

turtle.goto(x,y)

turtle.pd()

turtle.circle(-30,360)

#end o()

#定义函数,绘制字母n

def chr_n(x,y):

turtle.pensize(10)

turtle.color(160,82,45)

turtle.pu()

turtle.goto(x,y)

turtle.pd()

turtle.seth(270)

turtle.fd(60)

turtle.pu()

turtle.goto(x,y)

turtle.pd()

turtle.left(180)

turtle.circle(-30,180)

turtle.fd(60)

#end n()

#定义函数,绘制字母T

def chr_T(x,y):

turtle.pensize(10)

turtle.color(255,0,0)

turtle.pu()

turtle.goto(x,y)

turtle.pd()

turtle.seth(0)

turtle.fd(35)

turtle.pu()

turtle.goto(x+15,y)

turtle.pd()

turtle.right(90)

turtle.fd(35)

#end T()

#定义函数,绘制字母M

def chr_M(x,y):

turtle.pensize(10)

turtle.color(255,125,64)

turtle.pu()

turtle.goto(x,y)

turtle.pd()

turtle.seth(270)

turtle.fd(35)

turtle.pu()

turtle.goto(x,y)

turtle.pd()

turtle.left(45)

turtle.fd(25)

turtle.left(90)

turtle.fd(25)

turtle.seth(270)

turtle.fd(35)

#end M()

#定义函数,绘制蟒蛇图案1

def py1(x,y):

turtle.pensize(5)

turtle.pencolor(192,192,192)

turtle.fillcolor(0,0,255)

turtle.pu()

turtle.goto(x,y)

turtle.pd()

turtle.begin_fill()

turtle.seth(0)

turtle.fd(150)

turtle.seth(270)

turtle.fd(20)

turtle.right(90)

turtle.fd(180)

turtle.circle(50,90)

turtle.fd(100)

turtle.circle(80,90)

turtle.left(90)

turtle.fd(100)

turtle.circle(-50,90)

turtle.fd(120)

turtle.circle(50,90)

turtle.fd(100)

turtle.circle(55,90)

turtle.fd(60)

turtle.circle(105,90)

turtle.end_fill()

turtle.fillcolor(225,225,225)

turtle.pu()

turtle.goto(x+80,y+30)

turtle.pd()

turtle.begin_fill()

turtle.circle(15,360)

turtle.end_fill()

#end py1()

#定义函数,绘制蟒蛇图案2

def py2(x,y):

turtle.pensize(5)

turtle.pencolor(192,192,192)

turtle.fillcolor(255,215,0)

turtle.pu()

turtle.goto(x,y)

turtle.pd()

turtle.begin_fill()

turtle.seth(270)

turtle.fd(100)

turtle.circle(-55,90)

turtle.fd(120)

turtle.circle(50,90)

turtle.fd(100)

turtle.circle(50,90)

turtle.fd(60)

turtle.circle(110,90)

turtle.left(90)

turtle.fd(150)

turtle.right(90)

turtle.fd(20)

turtle.right(90)

turtle.fd(180)

turtle.circle(50,90)

turtle.fd(100)

turtle.circle(76,90)

turtle.end_fill()

turtle.fillcolor(225,225,225)

turtle.pu()

turtle.goto(x-80,y-270)

turtle.pd()

turtle.begin_fill()

turtle.circle(15,360)

turtle.end_fill()

#end py2()

def main():

turtle.colormode(255)

x=-100

y=60

py1(x-400,y+45)

py2(x-165,y+90)

chr_p(x,y-30)

chr_y(x+100,y-80)

chr_t(x+180,y-60)

chr_h(x+260,y-20)

chr_o(x+400,y-130)

chr_n(x+440,y-110)

chr_T(x+500,y+50)

chr_M(x+550,y+50)

main()

运行后得到的图案:

12fde34611c5

Pythonturtle是一个用于创建简单形和动画的模块,非常适合初学者学习编程中的绘概念。如果你想使用turtle来画出鸣人这个角色,首先你需要知道鸣人的基本特征,比如他的发型、服装等元素。 以下是一个简化的步骤,展示如何用turtle画出鸣人的大致轮廓: 1. 导入turtle模块并设置画笔大小和颜色: ```python import turtle turtle.speed(1) # 设置画笔速度,0最快,1中等,2慢,3最慢 turtle.pencolor('yellow') # 鸣人的头发通常是黄色 ``` 2. 绘制头部(圆形或椭圆): ```python turtle.begin_fill() turtle.circle(30) # 大致的圆形头 turtle.end_fill() ``` 3. 绘制面部特征(两个小圆作为眼睛,一个长形为嘴巴): ```python turtle.penup() turtle.goto(-15, -10) # 移动到合适位置 turtle.pendown() turtle.circle(5) # 左眼 turtle.penup() turtle.goto(-15, 10) # 右眼 turtle.pendown() turtle.circle(5) turtle.penup() turtle.goto(0, 0) # 嘴巴 turtle.pendown() turtle.forward(20) turtle.right(90) turtle.forward(10) turtle.left(90) turtle.forward(20) ``` 4. 绘制身体和衣服: ```python turtle.penup() turtle.goto(-40, 0) # 移动到身体位置 turtle.pendown() turtle.begin_fill() turtle.circle(60) # 身体 turtle.end_fill() turtle.penup() turtle.goto(-70, -20) # 衣服部分 turtle.pendown() turtle.begin_fill() turtle.color('blue', 'white') # 蓝色上衣 turtle.circle(40) # 上衣轮廓 turtle.end_fill() ``` 5. 最后,你可以添加一些细节,如手脚和标志性的螺旋丸符号,但这会更复杂些。 请注意,由于鸣人形象非常细致,用turtle可能无法精确还原,但以上代码提供了一个基本的绘画框架。如果你需要进一步了解如何改进细节或想要其他相关问题,请告诉我。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值