python使用turtle库绘制奥运五环

作者:lwtyh 时间:2021-06-21 04:22:44 

Turtle库是Python语言中一个很流行的绘制图像的函数库,想象一个小乌龟,在一个横轴为x、纵轴为y的坐标系原点,(0,0)位置开始,它根据一组函数指令的控制,在这个平面坐标系中移动,从而在它爬行的路径上绘制了图形。

效果图:

python使用turtle库绘制奥运五环


#奥运五环
import turtle
turtle.setup(1.0,1.0) #设置窗口大小
turtle.title("奥运五环")
#蓝圆
turtle.penup()
turtle.right(90)
turtle.forward(-50)
turtle.left(90)
turtle.forward(-200)
turtle.pendown()
turtle.pensize(10)
turtle.color("blue")
turtle.circle(100)
#黑圆
turtle.penup()
turtle.forward(250)
turtle.pendown()
turtle.pensize(10)
turtle.color("black")
turtle.circle(100)
#红圆
turtle.penup()
turtle.forward(250)
turtle.pendown()
turtle.pensize(10)
turtle.color("red")
turtle.circle(100)
#黄圆
turtle.penup()
turtle.forward(-275)
turtle.right(-90)
turtle.pendown()
turtle.pensize(10)
turtle.color("yellow")
turtle.circle(100)
#绿圆
turtle.penup()
turtle.left(-90)
turtle.forward(50)
turtle.right(90)
turtle.pendown()
turtle.pensize(10)
turtle.color("green")
turtle.circle(100)

下面看下python中turtle库的使用

turtle也叫海龟,是turtle绘图体系的python实现

turtle绘图体系:1969年诞生,是主要用于程序设计入门

turtle库是python语言的标准之一

标准库:python使用turtle库绘制奥运五环

第三方库:python使用turtle库绘制奥运五环

库:Library,包Package,模块Module,功能各不相同,但统称为模块

turtle库的原理:有一只海龟,在窗体正中心,在画布上游走,走过的轨迹形成了绘制的图形,海龟由程序控制,可以变换颜色,改变宽度等。。。

python使用turtle库绘制奥运五环python使用turtle库绘制奥运五环python使用turtle库绘制奥运五环python使用turtle库绘制奥运五环python使用turtle库绘制奥运五环python使用turtle库绘制奥运五环

这些都可以用python绘制出来

turyle绘图窗体的布置,使用的最小绘图单位是像素

位置关系

python使用turtle库绘制奥运五环

turtle.setup()函数设置窗体大小及位置;参数是高度,宽度,起始点的坐标,

四个参数,后两个参数是可选的

在绘图的时候setup()函数不是必须的,当需要设置起始点位置是采用

python使用turtle库绘制奥运五环

python使用turtle库绘制奥运五环

python使用turtle库绘制奥运五环

python使用turtle库绘制奥运五环

来源:https://www.cnblogs.com/lwtyh/p/12348135.html

标签:python,奥运五环,turtle库
0
投稿

猜你喜欢

  • Django values()和value_list()的使用

    2021-08-21 23:03:12
  • MySQL多表查询的具体实例

    2024-01-22 00:13:20
  • Python实现对中文文本分段分句

    2022-09-16 18:16:50
  • Python连接MySQL数据库的简单便捷方法

    2024-01-18 22:46:11
  • MySQL数据库高级数据操作之新增数据

    2024-01-18 17:46:38
  • Python数据报表之Excel操作模块用法分析

    2023-09-24 22:16:59
  • python 根据时间来生成唯一的字符串方法

    2022-12-25 14:49:48
  • 使用VSCode如何从github拉取项目的实现

    2023-02-02 10:32:35
  • encode脚本和normal脚本混用的问题与解决方法

    2024-04-22 13:02:39
  • 一个CSS图片切换效果代码

    2008-02-12 12:17:00
  • python-httpx的使用及说明

    2022-11-22 15:35:18
  • CSS3:文字阴影知多少

    2009-06-28 15:33:00
  • 详解Python列表赋值复制深拷贝及5种浅拷贝

    2022-07-16 16:22:41
  • python subprocess pipe 实时输出日志的操作

    2022-10-07 00:39:51
  • JavaScript变量类型以及变量作用域详解

    2023-08-12 08:50:17
  • 基于opencv和pillow实现人脸识别系统(附demo)

    2023-04-06 10:28:53
  • Javascript this 关键字 详解

    2024-06-07 15:51:18
  • SQL语句的执行原理分析

    2012-01-29 18:17:36
  • Python使用lambda抛出异常实现方法解析

    2022-02-06 21:59:52
  • python实现有效的括号判断实例代码

    2023-11-24 14:40:34
  • asp之家 网络编程 m.aspxhome.com