资源简介

学习CSDN公众号推荐python学习资料,继续完善学习,应用turtle工具 绘画小猪佩奇

资源截图

代码片段和文件信息

# -*- coding:UTF-8 -*-
from turtle import *
from test._mock_backport import right
from pip._vendor.pyparsing import Forward

def nose(xy):#鼻子
    penup()#提起笔
    goto(xy)#定位
    pendown()#落笔,开始画
    setheading(-30)#将乌龟的方向设置为to_angle/为数字(0-东、90-北、180-西、270-南)
    begin_fill()#准备开始填充图形
    a=0.4
    for i in range(120):
        if 0<=i<30 or 60<=i<90:
            a=a+0.08
            left(3) #向左转3度
            forward(a) #向前走a的步长
        else:
            a=a-0.08
            left(3)
            forward(a)
    end_fill()#填充完成
    penup()
    setheading(90)
    forward(25)
    setheading(0)
    forward(10)
    pendown()
    pencolor(255155192)#画笔颜色
    setheading(10)
    begin_fill()
    circle(5)
    color(1608245)#返回或设置pencolor和fillcolor
    end_fill()
    penup()
    setheading(0)
    forward(20)
    pendown()
    pencolor(255155192)
    setheading(10)
    begin_fill()
    circle(5)
    color(1608245)
    end_fill()
def head(xy):#头
    color((255155192)“pink“)
    penup()
    goto(xy)
    setheading(0)
    pendown()
    begin_fill()
    setheading(180)
    circle(300-30)
    circle(100-60)
    circle(80-100)
    circle(150-20)
    circle(60-95)
    setheading(161)
    circle(-30015)
    penup()
    goto(-100100)
    pendown()
    setheading(-30)
    a=0.4
    for i in range(60):
        if 0<=i<30 or 60<=i<90:
            a=a+0.08
            lt(3) #向左转3度
            fd(a) #向前走a的步长
        else:
            a=a-0.08
            lt(3)
            fd(a)
    end_fill()
def ears(xy): #耳朵
    color((255155192)“pink“)
    penup()
    goto(xy)
    pendown()
    begin_fill()
    setheading(100)
    circle(-5050)
    circle(-10120)
    circle(-5054)
    end_fill()
    penup()
    setheading(90)
    forward(-12)
    setheading(0)
    forward(30)
    pendown()
    begin_fill()
    setheading(100)
    circle(-5050)
    circle(-10120)
    circle(-5056)
    end_fill()
def eyes(xy):#眼睛
    color((255155192)“white“)
    penup()
    setheading(90)
    forward(-20)
    setheading(0)
    forward(-95)
    pendown()
    begin_fill()
    circle(15)
    end_fill()
    color(“black“)
    penup()
    setheading(90)
    forward(12)
    setheading(0)
    forward(-3)
    pendown()
    begin_fill()
    circle(3)
    end_fill()
    color((255155192)“white“)
    penup()
    seth(90)
    forward(-25)
    seth(0)
    forward(40)
    pendown()
    begin_fill()
    circle(15)
    end_fill()
    color(“black“)
    penup()
    setheading(90)
    forward(12)
    setheading(0)
    forward(-3)
    pendown()
    begin_fill()
    circle(3)
    end_fill()
def cheek(xy):#腮
    color((255155192))
    penup()
    goto(xy)
    pendown()
    setheading(0)
    begin_fill()
    circle(30)
    end_fill()
def mouth(xy): #嘴
    color(2396919)
    penup()
    goto(xy)
    pendown()
    setheading(-80)

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        6406  2018-06-08 11:48  CSDN推送小猪佩奇学习代码\new.py
     文件        6127  2018-06-08 11:50  CSDN推送小猪佩奇学习代码\源码.txt
     目录           0  2018-06-08 11:50  CSDN推送小猪佩奇学习代码\

评论

共有 条评论