python-turtle 画乔治爸爸

全部代码如下:

turtle主要的用法有:

turtle.setup(800, 600) #创建画布宽高
# 1)设置笔的颜色 - 画出来的线的颜色,颜色值是0~1的rgb值
turtle.pencolor(1, 0, 0)
# 2)设置线的宽度(粗细)
turtle.width(5)
# 3)设置笔的移动速度:1~10(1最小,10最大,0比10还大)
turtle.speed(1)
# 1)前进和后退(笔默认的方向是水平向右的)
# 前进:forward(距离)、fd(距离)
turtle.forward(100)
# 后退:back(距离)、bk(距离)
turtle.pencolor(0, 1, 0)
turtle.width(2)
# 后退
turtle.back(200)

# 2)移动到指定点
# goto(x坐标, y坐标)
turtle.goto(100, 200)

# 3)回到初始状态(初始位置(0,0)和初始角度(水平向右))
turtle.home()

 

# 1)left(角度)  -   从当前方向左旋转指定角度
# 2)right(角度)  -  从当前方右左旋转指定角度
# 3)setheading(角度) - 设置绝对角度
turtle.left(90)
turtle.right(90)
#  绝对角度向上
turtle.setheading(90)
turtle.forward(200)# 前进200

# 笔默认是放下状态(和画布接触的状态)
# turtle.up() - 笔抬起
turtle.up()
turtle.goto(100, 200)
# turtle.down()笔放下
turtle.down()
turtle.forward(100)
# 填充
turtle.fillcolor(1, 0, 0)
turtle.begin_fill()
# ----下面是画轮廓的代码-----
turtle.forward(100)
turtle.left(120)
turtle.forward(100)
turtle.home()
# ------上面是画轮廓的代码-----
turtle.end_fill()

 

 

# 导入库 和 创建画布大小
import turtle as t
t.setup(1169,700)
t.title("小猪-乔治爸爸")

# 运用函数 将坐标定位到画布的(0,0)上 方便后面的goto()函数运用
def change(x,y):
    return x - 570, 380 - y


t.penup() #抬起画笔
t.goto(change(198,165)) # 去到莫个点
t.write("韦老板,爱死你!!", font=("Arial", 40, "normal"), align="center")# 运用write可进行文本的输入

t.goto(0,0)
t.penup()
t.pencolor("#6c9D9D")
t.pensize(5)
t.fillcolor('#83C2C3')
t.begin_fill()
t.goto(change(414,364))
t.pendown()
t.goto(change(406,374))
t.goto(change(398,387))
t.goto(change(391,398))
t.goto(change(386,407))
t.goto(change(382,419))
t.goto(change(377,431))
t.goto(change(371,447))
t.goto(change(369,462))
t.goto(change(367,471))
t.goto(change(366,480))
t.goto(change(366,491))
t.goto(change(367,500))
t.goto(change(367,509))
t.goto(change(369,517))
t.goto(change(371,529))
t.goto(change(373,535))
t.goto(change(378,544))
t.goto(change(383,552))
t.goto(change(389,562))
t.goto(change(396,570))
t.goto(change(406,580))
t.goto(change(416,588))
t.goto(change(426,594))
t.goto(change(435,601))
t.goto(change(445,606))
t.goto(change(455,609))
t.goto(change(474,616))

t.goto(change(487,620))
t.goto(change(501,623))
t.goto(change(513,624))
t.goto(change(526,625))
t.goto(change(537,625))
t.goto(change(548,625))
t.goto(change(564,622))
t.goto(change(574,620))
t.goto(change(586,616))
t.goto(change(600,611))
t.goto(change(611,606))
t.goto(change(625,599))
t.goto(change(634,591))
t.goto(change(646,585))
t.goto(change(656,575))
t.goto(change(664,566))
t.goto(change(670,559))
t.goto(change(680,546))
t.goto(change(688,535))
t.goto(change(694,523))
t.goto(change(700,511))
t.goto(change(703,495))
t.goto(change(708,481))
t.goto(change(709,471))
t.goto(change(710,458))
t.goto(change(709,455))
t.goto(change(707,433))
t.goto(change(705,421))
t.goto(change(702,406))
t.goto(change(697,393))
t.goto(change(692,384))
t.goto(change(686,377))
t.goto(change(678,365))
t.goto(change(669,355))

t.end_fill()

t.begin_fill()
t.fillcolor('#F9D5DC')
t.pencolor("#B0A6AD")
t.goto(change(667,355))
t.goto(change(662,361))
t.goto(change(651,371))
t.goto(change(641,378))
t.goto(change(628,384))
t.goto(change(613,391))
t.goto(change(601,396))
t.goto(change(588,399))
t.goto(change(573,403))
t.goto(change(553,406))
t.goto(change(539,407))
t.goto(change(521,406))
t.goto(change(508,404))
t.goto(change(497,402))
t.goto(change(484,398))
t.goto(change(472,393))
t.goto(change(459,387))
t.goto(change(445,379))
t.goto(change(434,371))
t.goto(change(424,362))

t.goto(change(416,354))
t.goto(change(411,344))
t.goto(change(408,336))
t.goto(change(406,328))
t.goto(change(405,321))
t.goto(change(403,312))
t.goto(change(403,305))
t.goto(change(404,299))
t.goto(change(404,300))
t.goto(change(405,291))
t.goto(change(407,280))
t.goto(change(410,270))
t.goto(change(414,261))
t.goto(change(420,250))
t.goto(change(425,240))
t.goto(change(431,233))
t.goto(change(441,223))
t.goto(change(453,214))
t.goto(change(461,208))
t.goto(change(469,203))
t.goto(change(480,197))
t.goto(change(492,191))
t.goto(change(501,186))
t.goto(change(511,182))
t.goto(change(518,179))
t.goto(change(526,176))
t.goto(change(535,172))
t.goto(change(545,168))
t.goto(change(554,165))
t.goto(change(563,163))
t.goto(change(572,160))
t.goto(change(580,157))
t.goto(change(587,156))
t.goto(change(594,153))
t.goto(change(601,152))
t.goto(change(610,149))
t.goto(change(618,147))
t.goto(change(625,145))
t.goto(change(633,145))
t.goto(change(642,143))
t.goto(change(651,142))
t.goto(change(655,141))
t.goto(change(662,140))
t.goto(change(668,139))
t.goto(change(676,138))
t.goto(change(685,143))
t.goto(change(692,149))

t.goto(change(697,154))
t.goto(change(700,157))
t.goto(change(703,163))
t.goto(change(707,172))
t.goto(change(708,180))
t.goto(change(707,191))
t.goto(change(703,198))
t.goto(change(699,203))
t.goto(change(693,204))
t.goto(change(685,202))
t.goto(change(678,198))
t.goto(change(672,193))
t.goto(change(666,185))
t.goto(change(662,177))
t.goto(change(660,168))
t.goto(change(658,161))
t.goto(change(659,154))
t.goto(change(658,150))
t.goto(change(662,145))
t.penup()
t.goto(change(695,204))
t.pendown()
t.goto(change(689,212))
t.goto(change(685,216))
t.goto(change(678,222))
t.goto(change(671,227))
t.goto(change(664,233))
t.goto(change(657,236))
t.goto(change(649,241))

t.penup()
t.goto(change(663,220))
t.pendown()
t.goto(change(671,228))
t.goto(change(675,233))
t.goto(change(678,241))
t.goto(change(682,249))
t.goto(change(686,257))
t.goto(change(688,266))
t.goto(change(691,273))
t.goto(change(691,279))
t.goto(change(691,288))
t.goto(change(691,299))
t.goto(change(689,308))
t.goto(change(686,319))
t.goto(change(682,330))
t.goto(change(678,338))
t.goto(change(673,346))
t.goto(change(668,353))
t.end_fill()

# 腮红
t.penup()
t.goto(change(517,312))
t.pendown()
t.begin_fill()
t.fillcolor('#EAACBD')
t.pencolor("#EAB9C4")
t.circle(30)
t.end_fill()
# yan
t.penup()
t.goto(change(536,237))
t.pendown()

t.pencolor("#8A6F72")
t.circle(25)

t.penup()
t.goto(change(602,204))
t.pendown()
# t.pencolor("#EAB9C4")
t.circle(25)
# 眼眶
t.penup()
t.goto(change(397,284))
t.pendown()
t.goto(change(508,219))
t.penup()
t.goto(change(552,199))
t.pendown()
t.goto(change(584,183))
# yanqiu
t.penup()
t.fillcolor("#FFFFFF")
t.begin_fill()
t.pensize(3)
t.goto(change(536,226))
t.pendown()
t.pencolor("#8A6F72")
t.circle(15)
t.end_fill()
# 1
t.penup()
t.pencolor("#000000")
t.fillcolor("#000000")
t.begin_fill()
t.pensize(1)
t.goto(change(536,218))
t.pendown()
t.pencolor("#8A6F72")
t.circle(8)
t.end_fill()

t.penup()
t.fillcolor("#FFFFFF")
t.begin_fill()
t.pensize(3)
t.goto(change(602,194))
t.pendown()
t.pencolor("#8A6F72")
t.circle(15)
t.end_fill()
# 2
t.penup()
t.pencolor("#000000")
t.fillcolor("#000000")
t.begin_fill()
t.pensize(1)
t.goto(change(602,188))
t.pendown()
t.pencolor("#8A6F72")
t.circle(8)
t.end_fill()
#zui
t.pensize(5)
t.pencolor("#CE9DA8")
t.penup()
t.goto(change(600,314))
t.pendown()
t.goto(change(606,321))
t.goto(change(613,327))
t.goto(change(627,328))
t.goto(change(634,324))
t.goto(change(645,312))
t.goto(change(650,305))
t.goto(change(650,290))

# huxu
t.pencolor("#E8C6BA")
t.penup()
t.goto(change(578,362))
t.pendown()
t.goto(change(580,371))
t.goto(change(576,383))

t.penup()
t.goto(change(610,366))
t.pendown()
t.goto(change(611,372))
t.goto(change(613,381))

t.penup()
t.goto(change(637,360))
t.pendown()
t.goto(change(645,373))

t.penup()
t.goto(change(656,343))
t.pendown()
t.goto(change(669,355))

t.penup()
t.goto(change(672,324))
t.pendown()
t.goto(change(686,334))

t.penup()
t.goto(change(679,294))
t.pendown()
t.goto(change(695,302))

t.penup()
t.goto(change(581,274))
t.pendown()
t.goto(change(580,283))
t.goto(change(585,292))

t.penup()
t.goto(change(605,270))
t.pendown()
t.goto(change(607,278))

t.penup()
t.goto(change(622,263))
t.pendown()
t.goto(change(627,267))
t.goto(change(629,275))

t.penup()
t.goto(change(639,254))
t.pendown()
t.goto(change(652,257))
t.goto(change(658,263))

# 腿
t.pencolor("#E7D6DC")
t.penup()
t.goto(change(484,581))
t.pendown()
t.goto(change(455,681))
t.pencolor("#404140")
t.fillcolor("#404140")
t.begin_fill()
t.goto(change(448,685))
t.goto(change(452,691))
t.goto(change(460,693))
t.goto(change(479,699))
t.goto(change(491,697))
t.goto(change(489,692))
t.goto(change(479,687))
t.goto(change(467,684))
t.goto(change(455,682))
t.goto(change(449,685))
t.end_fill()

# you
# 腿
t.pencolor("#E7D6DC")
t.penup()
t.goto(change(605,613))
t.pendown()
t.goto(change(640,674))
t.pencolor("#404140")
t.fillcolor("#404140")
t.begin_fill()
t.goto(change(642,678))
t.goto(change(653,669))
t.goto(change(665,660))
t.goto(change(674,658))
t.goto(change(679,658))
t.goto(change(676,665))
t.goto(change(669,674))
t.goto(change(656,682))
t.goto(change(649,686))
t.goto(change(641,688))
t.end_fill()

# weiba
t.pencolor("#CCA6B1")
t.penup()
t.goto(change(379,555))
t.pendown()
t.goto(change(359,558))
t.goto(change(348,552))
t.goto(change(344,543))
t.goto(change(347,534))
t.goto(change(355,532))
t.goto(change(361,537))
t.goto(change(364,546))
t.goto(change(361,555))
t.goto(change(351,561))
t.goto(change(345,563))
t.goto(change(337,560))
t.goto(change(328,550))
# shou
t.penup()
t.goto(change(415,410))
t.pendown()
t.goto(change(385,410))
t.goto(change(364,413))
t.goto(change(338,416))
t.goto(change(319,424))
t.penup()
t.goto(change(341,417))
t.pendown()
t.goto(change(336,410))
t.goto(change(319,410))
t.penup()
t.goto(change(341,417))
t.pendown()
t.goto(change(338,426))
t.goto(change(324,438))
t.penup()
t.goto(change(709,409))
t.pendown()
t.goto(change(733,415))
t.goto(change(763,425))
t.goto(change(775,430))
t.goto(change(785,436))
#
t.penup()
t.goto(change(765,426))
t.pendown()
t.goto(change(771,420))
t.goto(change(787,420))
t.penup()
t.goto(change(764,426))
t.pendown()
t.goto(change(766,435))
t.goto(change(779,447))

# erduo
t.pencolor("#D8BAC6")
t.fillcolor("#EDCADB")
t.begin_fill()
t.penup()
t.goto(change(450,212))
t.pendown()
t.begin_fill()
# t.goto(change(450,212))
# t.goto(change(439,195))
t.goto(change(435,181))
t.goto(change(435,172))
t.goto(change(440,168))
t.goto(change(446,166))
t.goto(change(456,165))
t.goto(change(461,173))
t.goto(change(464,184))
t.goto(change(467,200))
# t.goto(change(439,195))
t.end_fill()
t.fillcolor("#EDCADB")
t.begin_fill()
t.penup()
t.goto(change(498,185))
t.pendown()
t.begin_fill()
t.goto(change(488,162))
t.goto(change(489,151))
t.goto(change(498,142))
t.goto(change(504,141))
t.goto(change(510,143))
t.goto(change(513,150))
t.goto(change(516,162))
t.goto(change(517,175))
t.end_fill()

# bizi
t.penup()
t.goto(change(673,168))
t.pendown()
t.goto(change(673,168))

t.pensize(6)
t.penup()
t.goto(change(687,160))
t.pendown()
t.hideturtle()
t.goto(change(687,160))
t.done()

#import ... 使用库中函数需要 库.函数 不会出现函数重名问题 #from .... import* 则可以直接使用函数名 #import .... as ....使代码量更少且不容易重名 import turtle #设置窗体大小和位置,4个参数中后两个可选为左上角坐标,setup函数不是必须的 turtle.setup(650,350,200,200) #绝对坐标 turtle.goto(x,y)海龟一开始在面的中心(0,0),到达(x,y) #相对坐标 海龟当前运行的方向是前进方向 turtle.fd(d) 或turtle.forward(d) #后方是后退方向 turtle.bk(d) #左侧是左侧方向 turtle.circle(r,angle)以左侧的某个点为圆心向左侧 #右侧是右侧方向 # 笔控制函数pen... # 一般成对出现: turtle.penup() 别名 turtle.pu() 不 # turtle.pendown() turtle.pd() # #笔宽度设置后一直有效 turtle.pensize(width) 或 turtle.width(width) #笔颜色 turtle.pencolor("purple")或 turtle.pencolor(0.63,0.13,0.94) 或 turtle.pencolor((0.63,0.13,0.94)) turtle.penup() turtle.fd(-250) turtle.pendown() turtle.pensize(25) turtle.pencolor("purple") #绝对角度 turtle角度坐标体系,类似数学平面直角坐标系,turtle.seth(angle)改变海龟行进角度,但不行进 或turtle.setheading() #相对角度 turtle.left(angle)向左改变角度 turtle.right(angle)向右改变角度 turtle.seth(-40) #turtle.circle(r,extent=None)绘制弧 默认圆心是左侧r距离的位置,弧度为360 -r右侧 for i in range(4): turtle.circle(40,80) turtle.circle(-40,80) turtle.circle(40,80/2) turtle.fd(40) turtle.circle(16,180) turtle.fd(40*2/3) turtle.done()
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值