Python使用turtle库绘制椭圆图形(自定义旋转角度、大小、颜色以及填充)

您所在的位置:网站首页 椭圆旋转公式 Python使用turtle库绘制椭圆图形(自定义旋转角度、大小、颜色以及填充)

Python使用turtle库绘制椭圆图形(自定义旋转角度、大小、颜色以及填充)

2024-07-16 22:55| 来源: 网络整理| 查看: 265

文章目录 一、使用说明二、代码三、使用说明

一、使用说明

确保电脑上安装了 turtle 库:

pip install -i https://mirrors.aliyun.com/pypi/simple turtle

调用库:

import turtle as t 二、代码

代码如下:

def ellipse(x, y, theta, l, size = 1, color = 'black'): """ Created on Tue Feb 8 20:19:39 2022 A function for drawing ellipses. @author: zq Parameters ---------- x : int 起始点的横坐标. y : int 起始点的纵坐标. theta : int 椭圆长轴与水平方向的夹角. l : int 椭圆长轴的长度(不建议太大),0 - 1 即可, 实际长度为该值的 800 倍左右. size : int 画笔的粗细程度,默认为 1. color : str 画笔的颜色,默认为黑色. """ t.penup() t.goto(x, y) t.setheading(theta + 270) t.pensize(size) t.pencolor(color) t.pendown() a = 0.3 for i in range(120): if 0


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3