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
投稿

猜你喜欢

  • CSS代码实现下划线样式的输入框效果

    2010-03-16 12:42:00
  • 服务端XMLHTTP(ServerXMLHTTP in ASP)基本应用(上)

    2008-11-11 12:49:00
  • pycharm使用anaconda全过程

    2023-07-19 04:57:12
  • PHP isset()与empty()的使用区别详解

    2023-11-21 10:28:39
  • Windows平台Python编程必会模块之pywin32介绍

    2023-11-05 10:45:35
  • 微信公众号可通过现金红包接口发放微信支付现金红包(附开发教程)

    2023-06-28 10:24:42
  • oracle 重置序列从指定数字开始的方法详解

    2023-07-05 02:40:04
  • 盘点十个超级好用的高级Python脚本

    2023-12-04 23:41:27
  • python爬虫beautiful soup的使用方式

    2023-05-17 08:13:22
  • 由浅入深漫谈margin属性

    2007-05-11 17:03:00
  • 如何取得MYSQL中ENUM列的全部可能值

    2009-07-30 08:53:00
  • Atlas—微软的Ajax工具包

    2007-09-07 09:52:00
  • MySQL应用技巧之内存使用线程独享

    2010-08-08 08:33:00
  • 基于Python实现的扫雷游戏实例代码

    2023-06-26 12:29:34
  • 使用python 获取进程pid号的方法

    2023-06-11 21:25:52
  • 利用python脚本如何简化jar操作命令

    2021-02-12 11:08:15
  • 初学者必读:经典的数据库记录分页代码

    2009-01-08 15:27:00
  • pandas DataFrame运算的实现

    2021-06-02 21:08:22
  • 用户凭什么跟你注册?

    2011-06-10 13:16:00
  • 图文详解vscode配置运行php项目完整版

    2023-05-28 22:56:03
  • asp之家 网络编程 m.aspxhome.com