用python画一个动漫人物,用python画动漫人物代码

大家好,小编来为大家解答以下问题,用python画一个动漫人物,用python画动漫人物代码,现在让我们一起来看看吧!

小猪佩奇

# coding:utf-8
import turtle as t
t.pensize(4) # 设置画笔的大小
t.colormode(255) # 设置GBK颜色范围为0-255
t.color((255,155,192),"pink") # 设置画笔颜色和填充颜色(pink)
t.setup(840,500) # 设置主窗口的大小为840*500
t.speed(10) # 设置画笔速度为10
#鼻子
t.pu() # 提笔
t.goto(-100,100) # 画笔前往坐标(-100,100)
t.pd() # 下笔
t.seth(-30) # 笔的角度为-30°
t.begin_fill() # 外形填充的开始标志
a=0.4
for i in range(120):
   if 0<=i<30 or 60<=i<90:
       a=a+0.08
       t.lt(3) #向左转3度
       t.fd(a) #向前走a的步长
   else:
       a=a-0.08
       t.lt(3)
       t.fd(a)
t.end_fill() # 依据轮廓填充
t.pu() # 提笔
t.seth(90) # 笔的角度为90度
t.fd(25) # 向前移动25
t.seth(0) # 转换画笔的角度为0
t.fd(10)
t.pd()
t.pencolor(255,155,192) # 设置画笔颜色
t.seth(10)
t.begin_fill()
t.circle(5) # 画一个半径为5的圆
t.color(160,82,45) # 设置画笔和填充颜色
t.end_fill()
t.pu()
t.seth(0)
t.fd(20)
t.pd()
t.pencolor(255,155,192)
t.seth(10)
t.begin_fill()
t.circle(5)
t.color(160,82,45)
t.end_fill()
#头
t.color((255,155,192),"pink")
t.pu()
t.seth(90)
t.fd(41)
t.seth(0)
t.fd(0)
t.pd()
t.begin_fill()
t.seth(180)
t.circle(300,-30) # 顺时针画一个半径为300,圆心角为30°的园
t.circle(100,-60)
t.circle(80,-100)
t.circle(150,-20)
t.circle(60,-95)
t.seth(161)
t.circle(-300,15)
t.pu()
t.goto(-100,100)
t.pd()
t.seth(-30)
a=0.4
for i in range(60):
   if 0<=i<30 or 60<=i<90:
       a=a+0.08
       t.lt(3) #向左转3度
       t.fd(a) #向前走a的步长
   else:
       a=a-0.08
       t.lt(3)
       t.fd(a)
t.end_fill()
#耳朵
t.color((255,155,192),"pink")
t.pu()
t.seth(90)
t.fd(-7)
t.seth(0)
t.fd(70)
t.pd()
t.begin_fill()
t.seth(100)
t.circle(-50,50)
t.circle(-10,120)
t.circle(-50,54)
t.end_fill()
t.pu()
t.seth(90)
t.fd(-12)
t.seth(0)
t.fd(30)
t.pd()
t.begin_fill()
t.seth(100)
t.circle(-50,50)
t.circle(-10,120)
t.circle(-50,56)
t.end_fill()
#眼睛
t.color((255,155,192),"white")
t.pu()
t.seth(90)
t.fd(-20)
t.seth(0)
t.fd(-95)
t.pd()
t.begin_fill()
t.circle(15)
t.end_fill()
t.color("black")
t.pu()
t.seth(90)
t.fd(12)
t.seth(0)
t.fd(-3)
t.pd()
t.begin_fill()
t.circle(3)
t.end_fill()
t.color((255,155,192),"white")
t.pu()
t.seth(90)
t.fd(-25)
t.seth(0)
t.fd(40)
t.pd()
t.begin_fill()
t.circle(15)
t.end_fill()
t.color("black")
t.pu()
t.seth(90)
t.fd(12)
t.seth(0)
t.fd(-3)
t.pd()
t.begin_fill()
t.circle(3)
t.end_fill()
#腮
t.color((255,155,192))
t.pu()
t.seth(90)
t.fd(-95)
t.seth(0)
t.fd(65)
t.pd()
t.begin_fill()
t.circle(30)
t.end_fill()
#嘴
t.color(239,69,19)
t.pu()
t.seth(90)
t.fd(15)
t.seth(0)
t.fd(-100)
t.pd()
t.seth(-80)
t.circle(30,40)
t.circle(40,80)
#身体
t.color("red",(255,99,71))
t.pu()
t.seth(90)
t.fd(-20)
t.seth(0)
t.fd(-78)
t.pd()
t.begin_fill()
t.seth(-130)
t.circle(100,10)
t.circle(300,30)
t.seth(0)
t.fd(230)
t.seth(90)
t.circle(300,30)
t.circle(100,3)
t.color((255,155,192),(255,100,100))
t.seth(-135)
t.circle(-80,63)
t.circle(-150,24)
t.end_fill()
#手
t.color((255,155,192))
t.pu()
t.seth(90)
t.fd(-40)
t.seth(0)
t.fd(-27)
t.pd()
t.seth(-160)
t.circle(300,15)
t.pu()
t.seth(90)
t.fd(15)
t.seth(0)
t.fd(0)
t.pd()
t.seth(-10)
t.circle(-20,90)
t.pu()
t.seth(90)
t.fd(30)
t.seth(0)
t.fd(237)
t.pd()
t.seth(-20)
t.circle(-300,15)
t.pu()
t.seth(90)
t.fd(20)
t.seth(0)
t.fd(0)
t.pd()
t.seth(-170)
t.circle(20,90)
#脚
t.pensize(10)
t.color((240,128,128))
t.pu()
t.seth(90)
t.fd(-75)
t.seth(0)
t.fd(-180)
t.pd()
t.seth(-90)
t.fd(40)
t.seth(-180)
t.color("black")
t.pensize(15)
t.fd(20)
t.pensize(10)
t.color((240,128,128))
t.pu()
t.seth(90)
t.fd(40)
t.seth(0)
t.fd(90)
t.pd()
t.seth(-90)
t.fd(40)
t.seth(-180)
t.color("black")
t.pensize(15)
t.fd(20)
#尾巴
t.pensize(4)
t.color((255,155,192))
t.pu()
t.seth(90)
t.fd(70)
t.seth(0)
t.fd(95)
t.pd()
t.seth(0)
t.circle(70,20)
t.circle(10,330)
t.circle(70,30)

结果:
在这里插入图片描述

多来a梦

# * -- utf-8 -- *
# Author: Tang
 
import turtle as t
 
t.speed(10)
t.pensize(8)
t.hideturtle()
t.screensize(500, 500, bg='white')
 
# 猫脸
t.fillcolor('#00A1E8')
t.begin_fill()
t.circle(120)
t.end_fill()
 
t.pensize(3)
t.fillcolor('white')
t.begin_fill()
t.circle(100)
t.end_fill()
 
t.pu()
t.home()
t.goto(0, 134)
t.pd()
t.pensize(4)
t.fillcolor("#EA0014")
t.begin_fill()
t.circle(18)
t.end_fill()
 
t.pu()
t.goto(7, 155)
t.pensize(2)
t.color('white', 'white')
t.pd()
t.begin_fill()
t.circle(4)
t.end_fill()
 
t.pu()
t.goto(-30, 160)
t.pensize(4)
t.pd()
t.color('black', 'white')
t.begin_fill()
a = 0.4
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a = a+0.08
        t.lt(3) #向左转3度
        t.fd(a) #向前走a的步长
    else:
        a = a-0.08
        t.lt(3)
        t.fd(a)
t.end_fill()
 
t.pu()
t.goto(30, 160)
t.pensize(4)
t.pd()
t.color('black', 'white')
t.begin_fill()
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a = a+0.08
        t.lt(3)  # 向左转3度
        t.fd(a)  # 向前走a的步长
    else:
        a = a-0.08
        t.lt(3)
        t.fd(a)
t.end_fill()
 
t.pu()
t.goto(-38,190)
t.pensize(8)
t.pd()
t.right(-30)
t.forward(15)
t.right(70)
t.forward(15)
 
t.pu()
t.goto(15, 185)
t.pensize(4)
t.pd()
t.color('black', 'black')
t.begin_fill()
t.circle(13)
t.end_fill()
 
t.pu()
t.goto(13, 190)
t.pensize(2)
t.pd()
t.color('white', 'white')
t.begin_fill()
t.circle(5)
t.end_fill()
 
t.pu()
t.home()
t.goto(0, 134)
t.pensize(4)
t.pencolor('black')
t.pd()
t.right(90)
t.forward(40)
 
t.pu()
t.home()
t.goto(0, 124)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(10)
t.forward(80)
 
t.pu()
t.home()
t.goto(0, 114)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(6)
t.forward(80)
 
t.pu()
t.home()
t.goto(0,104)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(0)
t.forward(80)
 
# 左边的胡子
t.pu()
t.home()
t.goto(0,124)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(170)
t.forward(80)
 
t.pu()
t.home()
t.goto(0, 114)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(174)
t.forward(80)
 
t.pu()
t.home()
t.goto(0, 104)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(180)
t.forward(80)
 
t.pu()
t.goto(-70, 70)
t.pd()
t.color('black', 'red')
t.pensize(6)
t.seth(-60)
t.begin_fill()
t.circle(80,40)
t.circle(80,80)
t.end_fill()
 
t.pu()
t.home()
t.goto(-80,70)
t.pd()
t.forward(160)
 
t.pu()
t.home()
t.goto(-50,50)
t.pd()
t.pensize(1)
t.fillcolor("#eb6e1a")
t.seth(40)
t.begin_fill()
t.circle(-40, 40)
t.circle(-40, 40)
t.seth(40)
t.circle(-40, 40)
t.circle(-40, 40)
t.seth(220)
t.circle(-80, 40)
t.circle(-80, 40)
t.end_fill()
 
# 领带
t.pu()
t.goto(-70, 12)
t.pensize(14)
t.pencolor('red')
t.pd()
t.seth(-20)
t.circle(200, 30)
t.circle(200, 10)
 
# 铃铛
t.pu()
t.goto(0, -46)
t.pd()
t.pensize(3)
t.color("black", '#f8d102')
t.begin_fill()
t.circle(25)
t.end_fill()
 
 
t.pu()
t.goto(-5, -40)
t.pd()
t.pensize(2)
t.color("black", '#79675d')
t.begin_fill()
t.circle(5)
t.end_fill()
 
t.pensize(3)
t.right(115)
t.forward(7)
 
t.mainloop()

结果:
在这里插入图片描述

皮卡丘


#!/usr/bin/env python 
# -*- coding:utf-8 -*-
from turtle import *
'''
绘制皮卡丘头部
'''
def face(x,y):
    """画脸"""
    begin_fill()
    penup()
    # 将海龟移动到指定的坐标
    goto(x, y)
    pendown()
    # 设置海龟的方向
    setheading(40)

    circle(-150, 69)
    fillcolor("#FBD624")
    # 将海龟移动到指定的坐标
    
    penup()
    goto(53.14, 113.29)
    pendown()
    
    setheading(300)
    circle(-150, 30)
    setheading(295)
    circle(-140, 20)
    print(position())
    forward(5)
    setheading(260)
    circle(-80, 70)
    print(position())
    penup()
    goto(-74.43,-79.09)
    pendown()


    penup()
    # 将海龟移动到指定的坐标
    goto(-144,103)
    pendown()
    setheading(242)
    circle(110, 35)
    right(10)
    forward(10)
    setheading(250)
    circle(80, 115)
    print(position())

    penup()
    goto(-74.43,-79.09)
    pendown()
    setheading(10)
    penup()
    goto(-144, 103)

    pendown()
    penup()
    goto(x, y)
    pendown()


    end_fill()

    # 下巴
    penup()
    goto(-50, -82.09)
    pendown()
    pencolor("#DDA120")
    fillcolor("#DDA120")
    begin_fill()
    setheading(-12)
    circle(120, 25)
    setheading(-145)
    forward(30)
    setheading(180)
    circle(-20, 20)
    setheading(143)
    forward(30)
    end_fill()
    # penup()
    # # 将海龟移动到指定的坐标
    # goto(0, 0)
    # pendown()

def eye():
    """画眼睛"""
    # 左眼
    color("black","black")
    penup()
    goto(-110, 27)
    pendown()
    begin_fill()
    setheading(0)
    circle(24)
    end_fill()
    # 左眼仁
    color("white", "white")
    penup()
    goto(-105, 51)
    pendown()
    begin_fill()
    setheading(0)
    circle(10)
    end_fill()
    # 右眼
    color("black", "black")
    penup()
    goto(25, 40)
    pendown()
    begin_fill()
    setheading(0)
    circle(24)
    end_fill()
    # 右眼仁
    color("white", "white")
    penup()
    goto(17, 62)
    pendown()
    begin_fill()
    setheading(0)
    circle(10)
    end_fill()
def cheek():
    """画脸颊"""
    # 右边
    color("#9E4406", "#FE2C21")
    penup()
    goto(-130, -50)
    pendown()
    begin_fill()
    setheading(0)
    circle(27)
    end_fill()

    # 左边
    color("#9E4406", "#FE2C21")
    penup()
    goto(53, -20)
    pendown()
    begin_fill()
    setheading(0)
    circle(27)
    end_fill()


def nose():
    """画鼻子"""
    color("black", "black")
    penup()
    goto(-40, 38)
    pendown()
    begin_fill()
    circle(7,steps = 3)
    end_fill()
def mouth():
    """画嘴"""
    color("black", "#F35590")
    # 嘴唇
    penup()
    goto(-10, 22)
    pendown()
    begin_fill()
    setheading(260)
    forward(60)
    circle(-11, 150)
    forward(55)
    print(position())
    penup()
    goto(-38.46, 21.97)
    pendown()
    end_fill()

    # 舌头
    color("#6A070D", "#6A070D")
    begin_fill()
    penup()
    goto(-10.00, 22.00)
    pendown()
    penup()
    goto(-14.29, -1.7)
    pendown()
    penup()
    goto(-52, -5)
    pendown()
    penup()
    goto(-60.40, 12.74)
    pendown()
    penup()
    goto(-38.46, 21.97)
    pendown()
    penup()
    goto(-10.00, 22.00)
    pendown()

    end_fill()

    color("black","#FFD624")

    penup()
    goto(-78, 15)
    pendown()
    begin_fill()
    setheading(-25)
    for i in range(2):
        setheading(-25)
        circle(35, 70)

    end_fill()
    color("#AB1945", "#AB1945")
    penup()
    goto(-52, -5)
    pendown()
    begin_fill()
    setheading(40)
    circle(-33, 70)
    goto(-16,-1.7)
    penup()
    goto(-18,-17)
    pendown()
    setheading(155)
    circle(25, 70)
    end_fill()


def ear():
    """画耳朵"""
    # 左耳
    color("black","#FFD624")
    penup()
    goto(-145, 93)
    pendown()
    begin_fill()
    setheading(165)
    circle(-248,50)
    right(120)
    circle(-248,50)
    end_fill()
    color("black", "black")
    penup()
    goto(-240, 143)
    pendown()
    begin_fill()
    setheading(107)
    circle(-170, 25)
    left(80)
    circle(229, 15)
    left(120)
    circle(300, 15)
    end_fill()

    # 右耳
    color("black", "#FFD624")
    penup()
    goto(30, 136)
    pendown()
    begin_fill()
    setheading(64)
    circle(-248, 50)

    right(120)
    circle(-248, 50)
    end_fill()
    color("black", "black")
    penup()
    goto(160, 200)
    pendown()
    begin_fill()
    setheading(52)
    circle(170, 25)
    left(116)
    circle(229, 15)
    left(71)
    circle(-300, 15)
    end_fill()
def setting():
    """设置参数"""
    pensize(2)
    # 隐藏海龟
    hideturtle()
    speed(10)
def main():
    """主函数"""
    setting()
    face(-132,115)
    eye()
    cheek()
    nose()
    mouth()
    ear()
    done()

if __name__ == '__main__':
    main()

结果:
在这里插入图片描述

小乌龟

import turtleturtle.setup(1000,800)turtle.speed(6)turtle.colormode(255)turtle.color((0,0,0),(60,100,30))turtle.penup()turtle.goto(0,-200)turtle.pendown()turtle.begin_fill()turtle.circle(200)turtle.end_fill()turtle.pensize(2)turtle.penup()turtle.goto(190,-60)turtle.pendown()turtle.goto(-190,-60)turtle.penup()turtle.goto(190,60)turtle.pendown()turtle.goto(-190,60)turtle.penup()turtle.goto(60,190)turtle.pendown()turtle.goto(60,-190)turtle.penup()turtle.goto(-60,190)turtle.pendown()turtle.goto(-60,-190)turtle.penup()turtle.pensize(1)turtle.goto(20,198)turtle.penup()turtle.goto(0,200)turtle.pendown()turtle.color((0,0,0),(60,80,30))turtle.begin_fill()a=1turtle.speed(0)for i in range(120):    if 0<=i<30 or 60<=i<=90:        a=a+0.04        turtle.lt(3)        turtle.fd(a)    else:        a=a-0.04        turtle.lt(3)        turtle.fd(a)turtle.penup()turtle.end_fill()
turtle.color((0,0,0),(255,255,255))turtle.goto(11,240)turtle.begin_fill()turtle.pendown()turtle.circle(5)turtle.end_fill()turtle.penup()turtle.end_fill()turtle.color((0,0,0),(255,255,255))turtle.goto(-11,240)turtle.begin_fill()turtle.pendown()turtle.circle(5)turtle.end_fill()turtle.penup()
turtle.color((0,0,0),(0,0,0))turtle.goto(10,240)turtle.begin_fill()turtle.pendown()turtle.circle(3)turtle.end_fill()turtle.penup()turtle.end_fill()turtle.color((0,0,0),(0,0,0))turtle.goto(-10,240)turtle.begin_fill()turtle.pendown()turtle.circle(3)turtle.end_fill()turtle.penup()turtle.color((0,0,0),(60,80,30))turtle.goto(-120,150)turtle.pendown()turtle.seth(30)turtle.begin_fill()a=0.3for i in range(120):    if 0<=i<30 or 60<=i<=90:        a=a+0.06        turtle.lt(3)        turtle.fd(a)    else:        a=a-0.06        turtle.lt(3)        turtle.fd(a)turtle.end_fill()turtle.penup()turtle.goto(120,150)turtle.pendown()turtle.seth(-30)a=0.3turtle.begin_fill()for i in range(120):    if 0<=i<30 or 60<=i<=90:        a=a+0.06        turtle.lt(3)        turtle.fd(a)    else:        a=a-0.06        turtle.lt(3)        turtle.fd(a)turtle.penup()turtle.end_fill()turtle.goto(-120,-160)turtle.pendown()turtle.seth(-210)turtle.begin_fill()a=0.5for i in range(120):    if 0<=i<30 or 60<=i<=90:        a=a+0.03        turtle.lt(3)        turtle.fd(a)    else:        a=a-0.03        turtle.lt(3)        turtle.fd(a) turtle.penup()turtle.end_fill()turtle.goto(120,-160)turtle.pendown()turtle.seth(210)turtle.begin_fill()a=0.5for i in range(120):    if 0<=i<30 or 60<=i<=90:        a=a+0.03        turtle.lt(3)        turtle.fd(a)    else:        a=a-0.03        turtle.lt(3)        turtle.fd(a)turtle.end_fill()turtle.penup()turtle.goto(0,-200)turtle.seth(0)turtle.pendown()
turtle.begin_fill()turtle.fd(10)turtle.seth(-105)turtle.fd(30)turtle.seth(105)turtle.fd(30)turtle.seth(0)turtle.fd(10)turtle.end_fill()turtle.hideturtle()turtle.mainloop()

结果:
在这里插入图片描述

五角圆环

import turtle as t
t.goto(100,0)
for i in range(50):
    t.left(80)
    t.fd(100)
    t.left(135)
    t.fd(105)

结果:
在这里插入图片描述

大风车

import turtle as t
t.goto(100,0)
for i in range(100):
    t.left(80)
    t.fd(100)
    t.left(135)
    t.fd(165)
    t.left(125)
    t.fd(115)

结果:
在这里插入图片描述
有什么错误的地方希望各位多多包含,也希望在评论区指出错误,小编会及时改正错误并从中吸取教训,同时也希望大家有什么好玩的程序能多多分享,把快乐带给更多人。

  • 6
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值