鱼C论坛

 找回密码
 立即注册
查看: 1383|回复: 0

[技术交流] 千秋万世,唯我中华!绘制源码。

[复制链接]
发表于 2021-9-30 16:37:53 From FishC Mobile | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
#调用turtle模块
import turtle
#屏幕分辨率设置
screen = turtle.Screen()
screen.setup(700,600)
t = turtle.Turtle()


#画笔运动速度
t.speed(5)
#画笔填充颜色  白
t.color('Snow')
#绘制四边形
#填充开始
t.begin_fill()
#提笔,不绘制
#t.penup()
#画笔移动到第一个点
t.goto(-100, 0)
#落笔,开始绘制
#t.pendown()
#画笔移动到第二个点
t.goto(-100, -50)
#画笔移动到第三个点
t.goto(0, -50)
#画笔移动到第4个点
t.goto(0, 0)
#画笔回到第一个点
t.goto(-100, 0)
#填充结束
t.end_fill()
t.goto(-50, -25)
t.color('red')
t.dot(20)
t.penup()
t.goto(0, 0)
t.pendown()

t.color('Snow')
t.goto(100, 0)
t.goto(100, -50)
t.goto(0,-50)
t.goto(0, 0)
def Tt(a,b):
  t.color('snow')
  t.begin_fill()
  t.goto(100, a)
  t.goto(100, b)
  t.goto(0, b)
  t.end_fill()
def Tt2(a,b):
  t.color('red')
  t.begin_fill()
  t.goto(100, a)
  t.goto(100, b)
  t.goto(0, b)
  t.end_fill()
g=0
h=-3
while h>-50:  
  Tt(g,h)
  g=g-3
  h=h-3
  Tt2(g,h)
  g=g-3
  h=h-3
t.color('snow')
t.begin_fill()
t.goto(100, h+3)
t.end_fill()

t.speed(5)


t.penup()
#画笔移动到第一个点
t.goto(0, 0)
#落笔,开始绘制
t.pendown()
t.color('blue')
t.begin_fill()
t.goto(0,-25)
t.goto(40,-25)
t.goto(40,0)
t.goto(0,0)
t.goto(2,-2)
t.end_fill()
t.color('Snow')
t.dot(2)
def Mtx(i,j):
  t.goto(i,j)
  while i<40:
    t.penup()
    t.goto(i,j)
    t.dot(2)
    i=i+4
Mtx(6,-2)
Mtx(4,-6)
Mtx(2,-10)
Mtx(4,-14)
Mtx(2,-18)
Mtx(4,-22)


#画笔运动速度
t.speed(1)
#画笔填充颜色  红
t.color('red')
#填充开始

#提笔,不绘制
t.penup()
t.hideturtle()
#画笔移动到第一个点
t.goto(-100, 0)
t.showturtle()
t.pendown()
t.goto(100, -100)
t.speed(5)
t.penup()
t.goto(100, 0)
t.speed(1)
#落笔,开始绘制
t.pendown()
t.goto(-100, -100)
t.speed(5)
t.begin_fill()
t.penup()
t.goto(-100, 0)
t.pendown()
#画笔移动到第二个点
t.goto(-100, -100)
#画笔移动到第三个点
t.goto(100, -100)
#画笔移动到第4个点
t.goto(100, 0)
#画笔回到第一个点
t.goto(-100, 0)
#填充结束
t.end_fill()



#画笔和填充的颜色  黄
t.color('yellow')
#绘制五角星函数定义 x,y位置 z画笔移动的距离
def Wjx(x,y,z):
#提起画笔,不绘制
  t.penup()
#画笔移到第一个点
  t.goto(x, y)
#初始化画笔方向
  t.setheading(0)
#落笔,开始绘制
  t.pendown()
#填充开始
  t.begin_fill()
#画笔顺时针转动72度  
  t.right(72)
#画笔移动z个像素
  t.forward(z)
#定义变量a
  a=0
#如果变量a小于4,进入循环
  while (a<4):
#画笔顺时针旋转144度
    t.right(144)
#画笔移动z个像素
    t.forward(z)
#每循环一次变量a加1
a=a+1
#填充结束
  t.end_fill()
#绘制大五角星
Wjx(-80,-10,30)
#绘制第二个五角星
Wjx(-60,-5,10)
#绘制第三个五角星
Wjx(-53,-17,10)
#绘制第四个五角星
Wjx(-53,-29,10)
#绘制第五个五角星
Wjx(-60,-41,10)
#隐藏画笔
t.hideturtle()


#文本绘制
t.hideturtle()
t.penup()
t.goto(-120, -150)
t.speed(1)
t.hideturtle()
t.color('red')
t.write('千', font = ('SimHei', 20, 'bold'))
t.goto(-95, -150)
t.write('秋', font = ('SimHei', 20, 'bold'))
t.goto(-70, -150)
t.write('万', font = ('SimHei', 20, 'bold'))
t.goto(-45, -150)
t.write('世', font = ('SimHei', 20, 'bold'))
t.goto(-20, -150)
t.write(',', font = ('SimHei', 20, 'bold'))
t.goto(5, -150)
t.write('唯', font = ('SimHei', 20, 'bold'))
t.goto(30, -150)
t.write('我', font = ('SimHei', 20, 'bold'))
t.goto(55, -150)
t.write('中', font = ('SimHei', 20, 'bold'))
t.goto(80, -150)
t.write('华', font = ('SimHei', 20, 'bold'))
t.goto(105, -150)
t.write('!',font = ('SimHei', 20, 'bold'))
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-14 10:11

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表