今天,我来给大家分享一个如何使用python绘制一个奥特曼
这个代码呢有一点点复杂
绘制出来的奥特曼呢是迪迦奥特曼。现在,我就给大家展示一下绘制奥特曼的代码
import turtle
def _goto_dist(x, y, x1, y1, towards=0, size=1):
turtle.pu()
turtle.goto(x, y)
turtle.seth(turtle.towards(x1, y1))
turtle.fd(turtle.distance(x1, y1) * size)
turtle.seth(towards)
turtle.pd()
return None
turtle.speed(0)
# 250*250标尺
_goto_dist(0, 0, 125, 125)
turtle.fd(-250)
turtle.seth(-90)
turtle.fd(250)
turtle.seth(0)
turtle.fd(250)
turtle.seth(90)
turtle.fd(250)
# 左耳朵(171,187,190)
_goto_dist(0, 0, -35, 108)
turtle.color('#ACBBBE')
turtle.begin_fill()
turtle.seth(0)
turtle.fd(12)
turtle.right(90)
turtle.fd(25)
turtle.right(90)
turtle.fd(12)
turtle.right(90)
turtle.fd(25)
turtle.end_fill()
# 身体()
_goto_dist(0, 0, 40, 58)
turtle.color('#D0DCDE')
turtle.begin_fill()
turtle.seth(190)
turtle.fd(40)
turtle.seth(180)
turtle.fd(20)
turtle.seth(225)
turtle.fd(30)
turtle.seth(90)
turtle.fd(15)
turtle.seth(180)
turtle.fd(20)
turtle.seth(275)
turtle.fd(40)
turtle.seth(-10)
turtle.fd(20)
turtle.seth(35)
turtle.fd(20)
turtle.seth(-65)
turtle.fd(20)
turtle.seth(-85)
turtle.fd(20)
# 左腿
turtle.seth(240)
turtle.fd(50)
turtle.seth(255)
turtle.fd(50)
# 左脚
# turtle.stamp()
turtle.seth(200)
turtle.fd(30)
turtle.seth(260)
turtle.fd(10)
turtle.seth(0)
turtle.fd(50)
turtle.seth(80)
turtle.fd(20)
turtle.seth(55)
turtle.fd(40)
turtle.seth(50)
turtle.fd(15)
turtle.seth(65)
turtle.fd(40)
# 右腿
turtle.seth(-10)
turtle.fd(10)
turtle.seth(-60)
turtle.fd(45)
turtle.seth(-40)
turtle.fd(20)
turtle.seth(-50)
turtle.fd(35)
# 右脚
turtle.seth(-80)
turtle.fd(20)
turtle.seth(0)
turtle.fd(45)
turtle.seth(120)
turtle.fd(13)
turtle.seth(150)
turtle.fd(25)
turtle.seth(110)
turtle.fd(50)
turtle.seth(140)
turtle.fd(10)
turtle.seth(120)
turtle.fd(50)
# 右侧身体
turtle.seth(80)
turtle.fd(20)
turtle.seth(70)
turtle.fd(40)
turtle.seth(180)
turtle.fd(35)
turtle.seth(110)
turtle.fd(20)
turtle.end_fill()
_goto_dist(0, 0, -2, 52)
turtle.color('#A7BBBE')
turtle.begin_fill()
turtle.seth(turtle.towards(-20, 52))
turtle.fd(turtle.distance(-20, 52))
turtle.seth(turtle.towards(-41, 32))
turtle.fd(turtle.distance(-41, 32))
turtle.seth(turtle.towards(-39, 2))
turtle.fd(turtle.distance(-39, 2))
turtle.seth(turtle.towards(-23, 13))
turtle.fd(turtle.distance(-23, 13))
turtle.seth(turtle.towards(-2, 52))
turtle.fd(turtle.distance(-2, 52))
turtle.end_fill()
# 左手
_goto_dist(0, 0, -40.61, 44.84)
turtle.color('#A7BBBE')
turtle.begin_fill()
turtle.seth(60)
turtle.fd(13)
turtle.seth(100)
turtle.fd(10)
turtle.seth(180)
turtle.fd(5)
turtle.seth(260)
turtle.fd(7)
turtle.seth(95)
turtle.fd(25)
turtle.seth(180)
turtle.fd(4)
turtle.seth(260)
turtle.fd(5)
turtle.seth(180)
turtle.fd(4)
turtle.seth(260)
turtle.fd(8)
turtle.seth(180)
turtle.fd(4)
turtle.seth(270)
turtle.fd(27)
turtle.seth(0)
turtle.end_fill()
# 身体副本01
_goto_dist(0, 0, 40, 58)
turtle.color('#373535')
turtle.begin_fill()
turtle.seth(190)
turtle.fd(40)
turtle.seth(200)
turtle.fd(20)
turtle.seth(245)
turtle.fd(15)
turtle.seth(-45)
turtle.fd(50)
turtle.seth(40)
turtle.fd(55)
turtle.end_fill()
# 身体副本02
_goto_dist(0, 0, -24, 30)
turtle.color('#859396')
turtle.begin_fill()
turtle.seth(turtle.towards(-21, 16))
turtle.fd(turtle.distance(-21, 16))
turtle.seth(turtle.towards(-13, -6))
turtle.fd(turtle.distance(-13, -6))
turtle.seth(turtle.towards(20, -35))
turtle.fd(turtle.distance(20, -35))
turtle.seth(turtle.towards(67, 0))
turtle.fd(turtle.distance(67, 0))
turtle.seth(turtle.towards(76, 25))
turtle.fd(turtle.distance(76, 25))
turtle.seth(turtle.towards(45, 27))
turtle.fd(turtle.distance(45, 27))
turtle.seth(turtle.towards(10, -6))
turtle.fd(turtle.distance(10, -6))
turtle.seth(turtle.towards(-24, 30))
turtle.fd(turtle.distance(-24, 30))
turtle.end_fill()
# 身体副本03
_goto_dist(0, 0, -62, 46)
turtle.color('#6C6DBD')
turtle.begin_fill()
turtle.seth(turtle.towards(-59, 5))
turtle.fd(turtle.distance(-59, 5))
turtle.seth(turtle.towards(-39, 2))
turtle.fd(turtle.distance(-39, 2))
turtle.seth(turtle.towards(-42, 45))
turtle.fd(turtle.distance(-42, 45))
turtle.seth(turtle.towards(-62, 46))
turtle.fd(turtle.distance(-62, 46))
turtle.end_fill()
_goto_dist(0, 0, -41, 31)
turtle.color('#B4604C')
turtle.begin_fill()
turtle.seth(turtle.towards(-41, 3))
turtle.fd(turtle.distance(-41, 3))
turtle.seth(turtle.towards(-29, 7))
turtle.fd(turtle.distance(-29, 7))
turtle.seth(turtle.towards(-41, 31))
turtle.fd(turtle.distance(-41, 31))
turtle.end_fill()
# 身体副本03
_goto_dist(0, 0, -16, 0)
turtle.color('#373535')
turtle.begin_fill()
turtle.seth(turtle.towards(0, -12))
turtle.fd(turtle.distance(0, -12))
turtle.seth(turtle.towards(21, -20))
turtle.fd(turtle.distance(21, -20))
turtle.seth(turtle.towards(47, -6))
turtle.fd(turtle.distance(47, -6))
turtle.seth(turtle.towards(68, 5))
turtle.fd(turtle.distance(68, 5))
turtle.seth(turtle.towards(65, -16))
turtle.fd(turtle.distance(65, -16))
turtle.seth(turtle.towards(83, -48))
turtle.fd(turtle.distance(83, -48))
turtle.seth(turtle.towards(78, -72))
turtle.fd(turtle.distance(78, -72))
turtle.seth(turtle.towards(51, -68))
turtle.fd(turtle.distance(51, -68))
turtle.seth(turtle.towards(34, -39))
turtle.fd(turtle.distance(34, -39))
turtle.seth(turtle.towards(24, -37))
turtle.fd(turtle.distance(24, -37))
turtle.seth(turtle.towards(11, -64))
turtle.fd(turtle.distance(11, -64))
turtle.seth(turtle.towards(-28, -68))
turtle.fd(turtle.distance(-28, -68))
turtle.seth(turtle.towards(-32, -56))
turtle.fd(turtle.distance(-32, -56))
turtle.seth(turtle.towards(-12, -24))
turtle.fd(turtle.distance(-12, -24))
turtle.seth(turtle.towards(-16, 0))
turtle.fd(turtle.distance(-16, 0))
turtle.end_fill()
# 右手
_goto_dist(0, 0, 42.29, 48.92)
turtle.color('#D0DCDE')
turtle.begin_fill()
turtle.seth(13)
turtle.fd(20)
turtle.seth(-15)
turtle.fd(15)
turtle.seth(-60)
turtle.fd(15)
turtle.seth(-100)
turtle.fd(15)
turtle.seth(210)
turtle.fd(65)
turtle.seth(180)
turtle.fd(8)
turtle.seth(147)
turtle.fd(55)
turtle.seth(85)
turtle.fd(25)
turtle.seth(-32)
turtle.fd(45)
turtle.seth(35)
turtle.fd(30)
turtle.seth(70)
turtle.fd(15)
turtle.end_fill()
# 右手
_goto_dist(0, 0, -23.41, 37.63)
turtle.color('#D0DCDE')
turtle.begin_fill()
turtle.seth(148)
turtle.fd(26)
turtle.left(90)
turtle.fd(4)
turtle.right(90)
turtle.fd(4)
turtle.left(90)
turtle.fd(8)
turtle.left(80)
turtle.fd(10)
turtle.right(85)
turtle.fd(5)
turtle.left(90)
turtle.fd(20)
turtle.left(30)
turtle.fd(9)
turtle.seth(86)
turtle.fd(22)
turtle.end_fill()
# 右手副本04 工的一横
_goto_dist(0, 0, 41, 51)
turtle.color('#B4604C')
turtle.begin_fill()
turtle.seth(turtle.towards(72, 17))
turtle.fd(turtle.distance(72, 17))
turtle.seth(turtle.towards(64, 12))
turtle.fd(turtle.distance(64, 12))
turtle.seth(turtle.towards(34, 40))
turtle.fd(turtle.distance(34, 40))
turtle.seth(turtle.towards(41, 51))
turtle.fd(turtle.distance(41, 51))
turtle.end_fill()
# 工的剩余部分
_goto_dist(0, 0, 52, 22)
turtle.color('#B4604C')
turtle.begin_fill()
turtle.seth(turtle.towards(32, 10))
turtle.fd(turtle.distance(32, 10))
turtle.seth(turtle.towards(41, -2))
turtle.fd(turtle.distance(41, -2))
turtle.seth(turtle.towards(29, -9))
turtle.fd(turtle.distance(29, -9))
turtle.seth(turtle.towards(10, 22))
turtle.fd(turtle.distance(10, 22))
turtle.seth(turtle.towards(18, 26))
turtle.fd(turtle.distance(18, 26))
turtle.seth(turtle.towards(27, 16))
turtle.fd(turtle.distance(27, 16))
turtle.seth(turtle.towards(46, 28))
turtle.fd(turtle.distance(46, 28))
turtle.seth(turtle.towards(52, 22))
turtle.fd(turtle.distance(52, 22))
turtle.end_fill()
_goto_dist(0, 0, 8, 23)
turtle.color('#6C6DBD')
turtle.begin_fill()
turtle.seth(turtle.towards(28, -8))
turtle.fd(turtle.distance(28, -8))
turtle.seth(turtle.towards(24, -12))
turtle.fd(turtle.distance(24, -12))
turtle.seth(turtle.towards(15, -11))
turtle.fd(turtle.distance(15, -11))
turtle.seth(turtle.towards(-24, 17))
turtle.fd(turtle.distance(-24, 17))
turtle.seth(turtle.towards(-24, 43))
turtle.fd(turtle.distance(-24, 43))
turtle.seth(turtle.towards(8, 23))
turtle.fd(turtle.distance(8, 23))
turtle.end_fill()
# 头(208,220,222)
_goto_dist(0, 0, 0, 50)
turtle.color('#D0DCDE')
turtle.begin_fill()
turtle.seth(-20)
turtle.circle(40, 45)
turtle.circle(60, 90)
turtle.circle(40, 45)
turtle.circle(40, 45)
turtle.circle(60, 90)
turtle.circle(40, 45)
turtle.end_fill()
# 右眼(254, 246, 112)
_goto_dist(0, 0, 20, 80)
turtle.color('#FEF66F')
turtle.begin_fill()
turtle.seth(-40)
turtle.circle(12, 45)
turtle.circle(20, 90)
turtle.circle(12, 45)
turtle.circle(12, 45)
turtle.circle(20, 90)
turtle.circle(12, 45)
turtle.end_fill()
# 左眼(253, 244, 111)
_goto_dist(0, 0, -10, 85)
turtle.color('#FEF66F')
turtle.begin_fill()
turtle.seth(20)
turtle.circle(12, 55)
turtle.circle(20, 70)
turtle.circle(12, 55)
turtle.circle(12, 55)
turtle.circle(20, 70)
turtle.circle(12, 55)
turtle.end_fill()
# 一根头发(172,187,190)
_goto_dist(0, 0, 55, 140)
turtle.color('#ACBBBE')
turtle.begin_fill()
turtle.seth(100)
turtle.fd(10)
turtle.seth(130)
turtle.fd(25)
turtle.seth(200)
turtle.fd(15)
turtle.seth(240)
turtle.fd(35)
turtle.seth(265)
turtle.fd(30)
turtle.seth(270)
turtle.fd(10)
turtle.seth(75)
turtle.fd(40)
turtle.seth(50)
turtle.fd(25)
turtle.seth(0)
turtle.fd(15)
turtle.seth(-50)
turtle.fd(20)
turtle.end_fill()
# 右耳朵(171,187,190)
_goto_dist(0, 0, 58, 100)
turtle.color('#ACBBBE')
turtle.begin_fill()
turtle.seth(-10)
turtle.fd(12)
turtle.right(90)
turtle.fd(25)
turtle.right(90)
turtle.fd(12)
turtle.right(90)
turtle.fd(25)
turtle.end_fill()
# 腿部修饰
_goto_dist(0, 0, 67, -4)
turtle.color('#6C6DBD')
turtle.begin_fill()
turtle.seth(turtle.towards(55, -16))
turtle.fd(turtle.distance(55, -16))
turtle.seth(turtle.towards(79, -60))
turtle.fd(turtle.distance(79, -60))
turtle.seth(turtle.towards(83, -49))
turtle.fd(turtle.distance(83, -49))
turtle.seth(turtle.towards(65, -16))
turtle.fd(turtle.distance(65, -16))
turtle.seth(turtle.towards(67, -4))
turtle.fd(turtle.distance(67, -4))
turtle.end_fill()
_goto_dist(0, 0, -16, -3)
turtle.color('#6C6DBD')
turtle.begin_fill()
turtle.seth(turtle.towards(-4, -26))
turtle.fd(turtle.distance(-4, -26))
turtle.seth(turtle.towards(-30, -63))
turtle.fd(turtle.distance(-30, -63))
turtle.seth(turtle.towards(-34, -56))
turtle.fd(turtle.distance(-34, -56))
turtle.seth(turtle.towards(-14, -24))
turtle.fd(turtle.distance(-14, -24))
turtle.seth(turtle.towards(-16, -3))
turtle.fd(turtle.distance(-16, -3))
turtle.end_fill()
_goto_dist(0, 0, -6, -89)
turtle.color('#C27361')
turtle.begin_fill()
turtle.seth(turtle.towards(-47, -103))
turtle.fd(turtle.distance(-47, -103))
turtle.seth(turtle.towards(-43, -92))
turtle.fd(turtle.distance(-43, -92))
turtle.seth(turtle.towards(-27, -83))
turtle.fd(turtle.distance(-27, -83))
turtle.seth(turtle.towards(0, -82))
turtle.fd(turtle.distance(0, -82))
turtle.seth(turtle.towards(-6, -89))
turtle.fd(turtle.distance(-6, -89))
turtle.end_fill()
_goto_dist(0, 0, 80, -100)
turtle.color('#C27361')
turtle.begin_fill()
turtle.seth(turtle.towards(104, -115))
turtle.fd(turtle.distance(104, -115))
turtle.seth(turtle.towards(106, -88))
turtle.fd(turtle.distance(106, -88))
turtle.seth(turtle.towards(100, -71))
turtle.fd(turtle.distance(100, -71))
turtle.seth(turtle.towards(96, -100))
turtle.fd(turtle.distance(96, -100))
turtle.seth(turtle.towards(70, -88))
turtle.fd(turtle.distance(70, -88))
turtle.seth(turtle.towards(80, -100))
turtle.fd(turtle.distance(80, -100))
turtle.goto(83, -97)
turtle.end_fill()
turtle.done()
这些代码其实还算可以,运行之后就能得到下面这个绘画作品