【python绘图库turtle实战】使用python绘图库turtle绘制:太阳花、彩虹线与小黄人【含完整源码】
本文使用python的turtle绘制3幅图代码示例:
1.绘制太阳花
import turtle as t
import time
t.color("red","yellow")
t.speed(10)
t.begin_fill()
for x in range(50):t.forward(200)t.left(170)
end_fill()
time.sleep(2)
2.绘制彩虹线
import turtle as t
from random import randint as rint
t.shape("turtle")
t.pensize(5)
t.colormode(255)
t.bgcolor("black")
t.tracer(False)
for x in range(700):t.color(rint(0,255),rint(0,255),rint(0,255))t.circle(2*(1+x/4),5)t.speed(30)t.tracer(True)
3.绘制小黄人
import turtle
t = turtle.Turtle()
wn = turtle.Screen()
turtle.colormode(255)
t.hideturtle()
t.speed(10)
t.penup()
t.pensize(4)
t.goto(100,0)
t.pendown()
t.left(90)
t.color((0,0,0),(255,255,0))
#身体绘制上色
t.begin_fill()
t.forward(200)
t.circle(100,180)
t.forward(200)
t.circle(100,180)
t.end_fill()
#右眼睛绘制上色
t.pensize(12)
t.penup()
t.goto(-100,200)
t.pendown()
t.right(100)
t.circle(500,23)t.pensize(3)
t.penup()
t.goto(0,200)
t.pendown()
t.seth(270)
t.color("black","white")
t.begin_fill()
t.circle(30)
t.end_fill()t.penup()
t.goto(15,200)
t.pendown()
t.color("black","black")
t.begin_fill()
t.circle(15)
t.end_fill()t.penup()
t.goto(35,205)
t.color("black","white")
t.begin_fill()
t.circle(5)
t.end_fill()
#左眼睛绘制上色
t.pensize(3)
t.penup()
t.goto(0,200)
t.pendown()
t.seth(90)
t.color("black","white")
t.begin_fill()
t.circle(30)
t.end_fill()t.penup()
t.goto(-15,200)
t.pendown()
t.color("black","black")
t.begin_fill()
t.circle(15)
t.end_fill()t.penup()
t.goto(-35,205)
t.color("black","white")
t.begin_fill()
t.circle(5)
t.end_fill()#嘴绘制上色
t.penup()
t.goto(-20,100)
t.pendown()
t.seth(270)
t.color("black","white")
t.begin_fill()
t.circle(20,180)
t.left(90)
t.forward(40)
t.end_fill()#裤子绘制上色
t.penup()
t.goto(-100,0)
t.pendown()
t.seth(0)
t.color("black","blue")
t.begin_fill()
t.forward(20)
t.left(90)
t.forward(40)
t.right(90)
t.forward(160)
t.right(90)
t.forward(40)
t.left(90)
t.forward(20)
t.seth(270)
t.penup()
t.goto(-100,0)
t.circle(100,180)
t.end_fill()#左裤子腰带
t.penup()
t.goto(-70,20)
t.pendown()
t.color("black","blue")
t.begin_fill()
t.seth(45)
t.forward(15)
t.left(90)
t.forward(60)
t.seth(270)
t.forward(15)
t.left(40)
t.forward(50)
t.end_fill()
t.left(180)
t.goto(-70,30)
t.dot()#右裤腰带
t.penup()
t.goto(70,20)
t.pendown()
t.color("black","blue")
t.begin_fill()
t.seth(135)
t.forward(15)
t.right(90)
t.forward(60)
t.seth(270)
t.forward(15)
t.right(40)
t.forward(50)
t.end_fill()t.left(180)
t.goto(70,30)t.dot()#脚
t.penup()
t.goto(4,-100)
t.pendown()
t.seth(270)
t.color("black","black")
t.begin_fill()
t.forward(30)
t.left(90)
t.forward(40)
t.seth(20)
t.circle(10,180)
t.circle(400,2)
t.seth(90)
t.forward(20)
t.goto(4,-100)
t.end_fill()t.penup()
t.goto(-4,-100)
t.pendown()
t.seth(270)
t.color("black","black")
t.begin_fill()
t.forward(30)
t.right(90)
t.forward(40)
t.seth(20)
t.circle(10,-225)
t.circle(400,-3)
t.seth(90)
t.forward(21)
t.goto(-4,-100)
t.end_fill()#左手
t.penup()
t.goto(-100,50)
t.pendown()
t.seth(225)
t.color("black","yellow")
t.begin_fill()
t.forward(40)
t.left(90)
t.forward(35)
t.seth(90)
t.forward(50)
t.end_fill()
#右手
t.penup()
t.goto(100,50)
t.pendown()
t.seth(315)
t.color("black","yellow")
t.begin_fill()
t.forward(40)
t.right(90)
t.forward(36)
t.seth(90)
t.forward(50)
t.end_fill()#
t.penup()
t.goto(0,-100)
t.pendown()
t.forward(30)#
t.penup()
t.goto(0,-20)
t.pendown()
t.color("yellow")
t.begin_fill()
t.seth(45)
t.forward(20)
t.circle(10,180)
t.right(90)
t.circle(10,180)
t.forward(20)
t.end_fill()#
t.penup()
t.color("black")
t.goto(-100,-20)
t.pendown()
t.circle(30,90)t.penup()
t.goto(100,-20)
t.pendown()
t.circle(30,-90)
#头顶
t.penup()
t.goto(2,300)
t.pendown()
t.begin_fill()
t.seth(135)
t.circle(100,40)
t.end_fill()t.penup()
t.goto(2,300)
t.pendown()
t.begin_fill()
t.seth(45)
t.circle(100,40)
t.end_fill()
【python绘图库turtle实战】使用python绘图库turtle绘制:太阳花、彩虹线与小黄人【含完整源码】相关推荐
- 区块链项目实战 - 使用以太坊/智能合约solidity,全栈开发区块链借贷记账小应用,含完整源码
本文使用区块链平台以太坊+智能合约实现一个区块链记账的功能,具体为: 借款人和贷款人以及数额被记录在区块链中.使用区块链地址来表示借款人或者贷款人. 若一个借款人多次向一个贷款人借钱,更新所有的数额之 ...
- Python实现修改图片分辨率(含完整源码)
Python实现修改图片分辨率(含完整源码) 在我们日常的工作和学习中,经常需要处理图片.有时候,我们可能需要修改图片的分辨率,以适应不同的需求.本文将介绍如何使用Python来实现修改图片的分辨率, ...
- Python编程:打造太空入侵者游戏(含完整源码)
Python编程:打造太空入侵者游戏(含完整源码) 太空入侵者这款游戏经典得让人不能忘怀,而Python语言的简单易学.快速开发的特性,使其成为实现该游戏的最好选择.在本篇文章中,我们将为读者呈现如何 ...
- python turtle绘图-案例集锦(小猪佩奇、哆啦A梦、小黄人、樱花树、皮卡丘、汉诺塔、高达、星空等)
1.小猪佩奇: import turtle as t t.pensize(4) t.hideturtle() t.colormode(255) t.color((255, 155, 192), &qu ...
- 【python数据分析】对淘商品类母婴购物数据进行分析(含完整源码)
前言 嗨喽,大家好呀~这里是爱看美女的茜茜呐 又到了学Python时刻~ 一.数据集 今天我们来看一个来着阿里云天池的数据集:淘母婴购物数据,有两个csv文件: 1.mum_baby.csv 它包 ...
- Python 爬取北京二手房数据,分析北漂族买得起房吗?(附完整源码)
来源:CSDN 本文约3500字,建议阅读9分钟. 本文根据Python爬取了赶集网北京二手房数据,R对爬取的二手房房价做线性回归分析,适合刚刚接触Python&R的同学们学习参考. 房价高是 ...
- 使用python 采集某网站全站美女图片 ,这么好看得图还不学起来(含完整源码)
本次目的: python 抓取某某站图片 本次亮点: 系统性分析页面 多页面数据解析 海量图片数据保存 开发环境 & 第三方模块: 解释器版本 >>> python 3.8 ...
- 美女如何无水印下载?python带你批量采集(含完整源码)
环境介绍: python 3.8 解释器 pycharm 2021专业版 >>> 激活码 编辑器 谷歌浏览器 谷歌驱动 selenium >>> 驱动 >&g ...
- Python批量采集商品数据并使用多线程(含完整源码)
前言 嗨喽,大家好,这里是魔王~ 本次目的: Python批量采集商品数据 知识点: 爬虫基本流程 非结构化数据解析 csv数据保存 线程池的使用 开发环境: python 3.8 pycharm r ...
最新文章
- zoj 2972 Hurdles of 110m (DP)
- OpenCV的滑块与回调函数
- php随机数字总和固定,php 随机生成固定长度整数、各种服务器请求方法
- 赞!史上最强音视频下载神器youtube-dl回归,GitHub75k星
- ReentrantLock可重入锁
- Directed Minimum Spanning Tree: Chu-Liu/Edmonds Algorithm
- 计算机考研复试面试问题总结——数据结构篇(含答案)
- java怎么实现读取文件_Java读取文件的简单实现方法
- camera link心得
- 联想Thinkpad sl400 7HC入手感觉
- 甘肃人社生物识别认证系统服务器,甘肃人社生物识别认证系统
- 物联网、大数据和云计算的基本关系和应用
- 2021年山东省职业院校技能大赛中职组“网络安全”赛项规程
- 21. 查询表sc——查询平均成绩大于等于90分的学生学号和平均成绩
- Android Studio提示 Cannot load key store: Keystore was tampered with, or password was incorre
- QQ安全检查未通过,禁止下载该文件
- 5-TAMRA标记LYS赖氨酸,5-TAMRA-Lysine结构式及光谱图分享
- 解析dump的几种方式
- SQL截取字符串(substring与patindex的使用)
- 微信开发者工具如何模拟调试扫描小程序二维码功能