赞
踩
---------------turtle源码集合---------------
Python教程91:关于海龟画图,Turtle模块需要学习的知识点
Python源码49:海龟画图turtle画美国旗
Python教程48:海龟画图turtle画太极八卦阵
Python源码47:海龟画图turtle画巴斯光年
Python源码46:海龟画图turtle画坤坤
Python源码45:海龟画图turtle画雪容融
Python源码44:海龟画图turtle,画2022卡塔尔世界杯吉祥物
Python教程43:海龟画图turtle画小樱魔法阵
Python教程42:海龟画图turtle画海绵宝宝
Python教程41:海龟画图turtle画蜡笔小新
Python教程40:使用turtle画一只杰瑞
Python教程39:使用turtle画美国队长盾牌
Python教程38:使用turtle画动态粒子爱心+文字爱心
Python教程37:使用turtle画一个戴帽子的皮卡丘
Python教程36:海龟画图turtle写春联
Python源码35:海龟画图turtle画中国结
Python源码31:海龟画图turtle画七道彩虹
Python源码30:海龟画图turtle画紫色的小熊
Python源码29:海龟画图turtle画太极图
Python源码28:海龟画图turtle画熊猫
Python源码27:海龟画图turtle画动态圆舞曲
Python源码26:海龟画图turtle画向日葵
Python源码25:海龟画图turtle画小猪佩奇
Python源码24:使用海龟画图turtle画滑板
Python源码23:使用海龟画图turtle画小狗狗
Python源码22:使用海龟画图turtle画今天日期
Python源码21:使用海龟画图turtle画太阳,云朵,房子,绿树
Python源码20:使用海龟画图turtle画一个会动的星空
Python源码19:海龟画图turtle画螺旋的彩色的逐渐放大的文字
Python源码18:使用海龟画图turtle画捂脸表情
Python源码17:使用海龟画图turtle画五星红旗
Python源码16:使用海龟画图turtle画会动的时钟
Python源码15:使用海龟画图turtle画小黄人
Python源码14:使用海龟画图turtle画我的城堡
Python源码分享13:使用海龟画图turtle画一个会眨眼的皮卡丘
Python源码分享12:使用turtle画彩色六边形
Python源码分享11:使用海龟画图turtle画航天火箭
Python源码分享10:使用海龟画图turtle画哆啦A梦
Python源代码分享:02海龟画图五角星
Python源代码分享:03画一个奥运五环图
Python源代码分享:05使用turtle模块绘制一个彩色螺旋图案
Python源代码分享:07画满天繁星
Python源码分享08:使用turtle画一朵玫瑰花
Python源码分享10:使用海龟画图turtle画哆啦A梦
Python源码分享11:使用海龟画图turtle画航天火箭
Python源码分享12:使用turtle画彩色六边形
1.三角形、正方形、五边形、六边形的绘制
# @Author : 小红牛 # 微信公众号:WdPython import turtle as t t.setup(1000, 500) # 画布的大小及位置 t.penup() t.goto(-400, 100) t.pendown() t.pensize(5) # 画笔的粗细 # 1. 三角形 t.color("purple") for i in range(3): t.fd(100) t.seth(-120 * (i+1)) # 2.正方形 t.penup() t.fd(200) t.pendown() t.color("blue") for i in range(4): t.fd(100) t.seth(-90 * (i+1)) # 3.正五边形 t.penup() t.fd(200) t.pendown() t.color("red") for i in range(5): t.fd(100) t.seth(-72 * (i+1)) # 4. 正六边形 t.penup() t.fd(250) t.pendown() t.color("green") for i in range(6): t.fd(100) t.seth(-60 * (i+1)) t.done()
2.圆、同心圆、边切圆
# 2.1画圆,绘制一个指定半径和角度e的圆或弧线
turtle.circle(30)
circle(50,steps=3) # 三角形
circle(120, 180) # 半圆
2.2绘制边切圆
# @Author : 小红牛 # 微信公众号:WdPython import turtle as t t.pensize(2) t.color('red') t.circle(20) t.color('green') t.circle(40) t.color('blue') t.circle(80) t.color('black') t.circle(100) t.done() ''' # 可以使用for循环实现,使用列表存放颜色和半径 import turtle color = ['red','green','blue','black'] r = [20,40,80,100] for i in range(4): t.pencolor(color[i]) t.circle(r[i]) t.done() '''
2.3.绘制同心圆,第一个圆以坐标 (0.00, -20.00)起笔,同心圆半径的坐标为(0,0)。由第一个圆的起笔位置,来确定第二个圆的起笔位置。
确定圆心,即第一个圆的位置。
确定圆的大小。
移动画笔到下一个圆的圆心位置。
重复画圆的过程。
import turtle as t colors = ["red", "purple", "skyblue", "yellow", "hotpink", "green", "blue", "black", "darkred"] # 圆的颜色 r = [20, 30, 60, 90, 120, 180, 210] # 圆的半径 t.pensize(2) for i in range(7): t.penup() t.goto(0, -r[i]) # 第一个圆以坐标 (0.00, -20.00)起笔,同心圆半径的坐标为(0,0) print(t.position()) t.pendown() t.pencolor(colors[i]) t.circle(r[i]) t.done()
3.画五角星
import turtle as t
t.color('red')
# 画五角星
for _ in range(5):
t.forward(200)
t.right(144)
# 关闭窗口
t.done()
4.通过椭圆公式x2/a2+y2/b2=1 通过改变x值来得到y的值下面这代码,通过改变a和b的值即可得到相应椭圆。
import turtle as t import math a = 120 # 椭圆的长半轴 b = 80 # 椭圆的短半轴 t.penup() t.goto(-a, 0) t.pendown() for i in range(a * 2 + 1): y = math.sqrt((b * b) * (1 - (((i - a) ** 2) / (a * a)))) t.goto(i - a, y) t.penup() t.goto(-a, 0) t.pendown() for i in range(a * 2 + 1): y = -math.sqrt((b * b) * (1 - (((i - a) ** 2) / (a * a)))) t.goto(i - a, y) t.done()
完毕!!感谢您的收看
----------★★历史博文集合★★----------
我的零基础Python教程,Python入门篇 进阶篇 视频教程 Py安装py项目 Python模块 Python爬虫 Json Xpath 正则表达式 Selenium Etree CssGui程序开发 Tkinter Pyqt5 列表元组字典数据可视化 matplotlib 词云图 Pyecharts 海龟画图 Pandas Bug处理 电脑小知识office自动化办公 编程工具
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。