时钟

import turtle as t

import datetime as dt

#画出背景

game = t.Screen()

game.bgcolor("white")

game.setup(600,600)

game.tracer(0)

#定义画笔属性

pen = t.Turtle()

pen.speed(10)

pen.ht()

pen.up()

def draw_clock(h,m,s):

#画圈

pen.clear()

pen.up()

pen.color("black")

pen.pensize(3)

pen.seth(0)

pen.goto(0,-210)

pen.down()

pen.circle(210)

#画刻度

pen.up()

pen.goto(0,0)

pen.seth(90)

#大刻度

for _ in range(12):

pen.fd(190)

pen.down()

pen.fd(20)

pen.up()

pen.goto(0,0)

pen.rt(30)

#小刻度

for _ in range(60):

pen.up()

pen.goto(0,0)

pen.rt(6)

pen.fd(200)

pen.down()

pen.color('black')

pen.pensize(2)

pen.fd(10)

#画秒针

pen.up()

pen.home()

pen.down()

pen.color("red")

pen.pensize(3)

pen.seth(90)

pen.rt(s/60*360)

pen.fd(160)

pen.stamp()

#画分针

pen.up()

pen.home()

pen.down()

pen.color("Gold")

pen.pensize(3)

pen.seth(90)

pen.rt(m/60*360)

pen.fd(120)

pen.stamp()

#画时针

pen.up()

pen.home()

pen.down()

pen.color("Maroon")

pen.pensize(3)

pen.seth(90)

pen.rt(h/12*360)

pen.fd(80)

pen.stamp()

#问候字体

pen.up()

pen.goto(-175,250)

pen.color('orange')

font1 = ('宋体',20,'bold')

hello = "{}年你好!今天是{}月{}日".format(now.year,now.month,now.day)

pen.write(hello,"center",font=font1)

while True:

game.update()

now = dt.datetime.now()

draw_clock(now.hour,now.minute,now.second)

game.mainloop()

太极图

import turtle

def Taichi(R,r):

'''

R:整个大圆半径;

r:两个最小圆半径

'''

#大圆左白右黑

p.up()

p.goto(0,-R)

p.down()

p.pencolor('black')

p.fillcolor('black')

p.begin_fill()

p.circle(R,180)

p.end_fill()

p.pencolor('white')

p.fillcolor('white')

p.begin_fill()

p.circle(R,180)

p.end_fill()

#半圆下黑上白

p.pencolor('black')

p.fillcolor('black')

p.begin_fill()

p.circle(R/2,-180)

p.end_fill()

p.right(180)

p.pencolor('white')

p.fillcolor('white')

p.begin_fill()

p.circle(R/2,180)

p.end_fill()

#小圆上黑下白

p.up()

p.home()

p.goto(0,R/2-r)

p.down()

p.pencolor('black')

p.fillcolor('black')

p.begin_fill()

p.circle(r)

p.end_fill()

p.up()

p.goto(0,-(R/2+r))

p.down()

p.pencolor('white')

p.fillcolor('white')

p.begin_fill()

p.circle(r)

p.end_fill()

if __name__ == '__main__':

s = turtle.Screen()

s.bgcolor('Silver')

s.screensize(800,800)

p = turtle.Turtle()

p.shape('turtle')

p.ht()

s.tracer(10,0)

Taichi(200,30)

s.mainloop()

玫瑰

大部分都是通过调整圆半径、弧度和方向绘制的,过程需一步步尝试,比较繁琐,仅供参考

import turtle

#渐大

def increases(a,z,f):

#a:画笔起始大小;z:画笔终止大小;f:渐变拉伸距离

for i in range(a,z):

p.pensize(i)

p.forward(f)

#渐小

def smaller(a,z,f):

for i in range(a,z,-1):

p.pensize(i)

p.forward(f)

#花蕊

def flower():

#右下

p.up()

p.home()

p.goto(0,0)

p.pencolor('red')

p.left(15)

p.down()

increases(1,7,5)

p.circle(50,70)

p.forward(60)

p.circle(-100,15)

smaller(7,1,5)

#左下

p.up()

p.home()

p.goto(-20,0)

p.left(180)

p.down()

increases(1,7,5)

p.circle(-60,85)

p.forward(60)

p.circle(100,15)

smaller(7,1,5)

#右边

p.up()

p.home()

p.goto(80,250)

p.left(10)

p.down()

increases(1,5,5)

p.circle(-20,120)

p.circle(-130,20)

p.forward(50)

p.circle(100,15)

smaller(5,1,6)

#左边

p.up()

p.home()

p.goto(-110,240)

p.left(180)

p.down()

increases(1,5,5)

p.circle(30,130)

p.circle(130,15)

p.forward(20)

p.circle(-100,35)

smaller(5,1,7)

#左上

p.up()

p.home()

p.goto(0,270)

p.left(150)

p.down()

increases(1,5,5)

p.circle(60,120)

p.circle(60,30)

p.circle(-50,25)

smaller(5,1,5)

#右上

p.up()

p.home()

p.goto(8,271)

p.left(10)

p.down()

increases(1,5,5)

p.circle(-40,80)

p.circle(-30,90)

p.forward(5)

p.circle(250,25)

smaller(4,1,6)

#右中

p.up()

p.home()

p.goto(65,215)

p.left(-95)

p.down()

increases(1,5,5)

p.circle(200,6)

smaller(5,1,7)

#顶右1

p.up()

p.home()

p.goto(-10,260)

p.left(10)

p.down()

increases(1,5,5)

p.circle(-25,120)

p.circle(-20,40)

p.forward(15)

smaller(4,1,6)

#顶右2

p.up()

p.home()

p.goto(-20,240)

p.left(10)

p.down()

increases(1,5,5)

p.circle(-10,200)

smaller(4,1,6)

#顶左1

p.up()

p.home()

p.goto(-20,255)

p.left(165)

p.down()

increases(1,5,5)

p.forward(10)

p.circle(35,190)

p.circle(90,25)

smaller(4,1,5)

#顶左2

p.up()

p.home()

p.goto(-25,240)

p.left(170)

p.down()

increases(1,5,5)

p.circle(15,230)

smaller(4,1,6)

def leaf():

#叶子

#左1

p.pencolor('Green')

p.up()

p.home()

p.goto(-80,0)

p.left(220)

p.down()

increases(1,5,5)

p.circle(80,50)

p.circle(-80,60)

smaller(4,1,5)

#左2

p.right(210)

increases(1,5,5)

p.circle(70,80)

p.circle(-100,40)

smaller(4,1,5)

#左3

p.right(100)

increases(1,5,5)

p.circle(-200,40)

smaller(4,1,5)

#左4

p.left(155)

increases(1,5,5)

p.circle(200,45)

smaller(4,1,5)

#右1

p.up()

p.home()

p.goto(45,8)

p.right(45)

p.down()

increases(1,5,5)

p.circle(-300,20)

p.circle(100,40)

smaller(4,1,5)

#右2

p.left(200)

increases(1,5,5)

p.circle(-100,60)

p.circle(70,20)

smaller(5,1,7)

#小叶

p.up()

p.home()

p.goto(70,30)

p.left(20)

p.down()

increases(1,5,5)

p.circle(50,30)

smaller(4,1,5)

p.right(150)

increases(1,5,5)

p.circle(-50,70)

smaller(4,1,5)

#花柄

p.up()

p.home()

p.goto(-30,-60)

p.down()

p.right(80)

increases(1,5,5)

p.circle(-700,20)

p.fd(60)

smaller(4,1,5)

p.up()

p.home()

p.goto(10,-170)

p.down()

p.right(90)

increases(1,5,5)

p.circle(-700,10)

p.fd(55)

smaller(4,1,5)

#刺

p.up()

p.home()

p.goto(-25,-250)

p.down()

p.left(125)

increases(1,5,5)

p.fd(10)

smaller(5,1,5)

p.left(165)

increases(1,5,5)

p.fd(40)

smaller(5,1,5)

#画布设置

s = turtle.Screen()

s.bgcolor('LightYellow')

s.setup(1400,800)

s.title('送你花花')

s.tracer(1,10)

#画笔设置

p = turtle.Turtle()

p.shape('turtle')

p.speed('fastest')

p.ht()

#画花和叶

flower()

leaf()

s.mainloop()

python import turtle as t_Python Turtle模块的简单应用相关推荐

  1. python import turtle as t_Python turtle库的学习笔记

    (2)from turtle import * 对turtle库中函数调用采用( )形式,不再使用turtle.作为前导: (3)  import turtle as t 保留字as将turtle库给 ...

  2. python import 找不到指定模块_Pycharm中出现ImportError:DLL load failed:找不到指定模块的解决方法...

    关于conda安装matplotlib报错 最近在师姐机器上跑实验的时候,想利用matplotlib包来绘制损失曲线图,安装过程中碰到了一些小麻烦,感觉之前好像也碰到过类似的问题,网上一搜什么nump ...

  3. python import turtle as t_Python编程小记:turtle库

    一.基础小结 turtle库是python标准库之一,入门级绘图库.import turtle之后即可使用. 1.绘图窗口设置命令 turtle.setup(400,300,200,100):参数以此 ...

  4. python turtle_Python简单图形化程序模块——Turtle模块

    大头科技社为了满足一些小伙伴们的需求,特在头条每天更新python的入门.精通课程. 课程怎么找得到?代码附件?讲课的资料在哪?关注大头科技社,点开主页的文章页面,找"python" ...

  5. python turtle画笑脸_turtle 模块-画笑脸

    import turtle import time        #计时包 t=turtle.Turtle() #t.shape('turtle') turtle.colormode(255) t.p ...

  6. 三、Python学习(二)海龟模块turtle画笔介绍及命令详解(画圆)

    1.画笔的状态 在画布上,默认有一个坐标原点为画布中心的坐标轴,坐标原点上有一只面朝x轴正方向小乌龟.这里我们描述小乌龟时使用了两个词语:坐标原点(位置),面朝x轴正方向(方向),turtle绘图中, ...

  7. python turtle什么意思_python模块turtle简单用法

    ##初始化turtle: t = turtle.Turtle() 或者 t = turtle.Pen() ##查询turtle状态 #位置 t.position() #箭头朝向,箭头朝向按照顺时针或者 ...

  8. python turtle库画图案-Python基础图形绘制库——turtle

    (1).介绍 turtle库也叫海龟库,是turtle绘图体系的Python实现.turtle库是Python语言的标准库之一,是入门级的图形绘制函数库. turtle绘图体系:也叫海龟绘图系统,它是 ...

  9. python turtle方向_Python turtle.left()用法及代码示例

    turtle 模块以面向对象和面向过程的方式提供 turtle 图形基元.由于它使用Tkinter作为基础图形,因此需要安装有Tk支持的Python版本. turtle .left() turtle. ...

最新文章

  1. php 降低图像大小,在PHP中调整图像大小
  2. java mediator_java—mediator中介模式
  3. 从mysql到大数据(二)--数据库的认识
  4. 没业绩怎么写好年终总结?这样写总结年终奖翻倍!
  5. 简易新闻客户端android
  6. 用机器学习来预测情侣间何时吵架,这是一个很实用的算法
  7. Python常见陷阱
  8. QLineEdit使用正则表达式小剖析
  9. python sdklive2d_纯干货!live2d动画制作简述以及踩坑
  10. SSH 只能用于远程 Linux 主机?那说明你见识太小了!
  11. WGS84经纬度坐标转化成UTM坐标
  12. c2c网上商店管理与推广
  13. Spark大数据分析与实战:Spark SQL编程初级实践
  14. eclipse提示:This tag and its children can be replaced by one lt;TextView/gt; and a compound drawable
  15. html5 gif 只播放一次,使用JS和canvas实现gif动图的停止和播放代码
  16. android电视APP开机自启动,安卓电视、机顶盒如何开机自动启动看电视直播-今日头条...
  17. 3-----A Forcast for Bicycle Rental Demand Based on Random Forests and Multiple Linear Regression
  18. vip2-day22 MySQL 基础语句
  19. Android12之OpenSL ES基础数据结构总结(十)
  20. linux tts 中文,基于linux的中文TTS 简单实现

热门文章

  1. 笔记本开机数字小键盘自动打开问题
  2. CAD软件中文本如何屏蔽
  3. 最大流 最小费用最大流模板
  4. 《校园墙》小程序可行性分析
  5. 数字证书申请流程(双证)
  6. 不越狱无插件实现 sparrow 推送通知
  7. 温暖的光,坚定的飞翔
  8. 面向对象三大特征---继承
  9. 帝国cms模板仿后台登录界面源码
  10. LeetCode HOT 100 --- 2021/7/30