脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服务器之家 - 脚本之家 - Python - python实现画五角星和螺旋线的示例

python实现画五角星和螺旋线的示例

2021-05-18 01:00果冻先生的专栏 Python

今天小编就为大家分享一篇python实现画五角星和螺旋线的示例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

如下所示:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# -*- coding:utf-8 -*-
__author__ = "zhangguodong"
__time__ = "2017.11.16"
 
import turtle
 
turtle.title("张国栋画五角星")
turtle.setup(500,300,0,0)
turtle.fillcolor("red")
turtle.begin_fill()
 
while true:
  turtle.forward(220)
  turtle.right(144)
  if abs(turtle.pos()) < 1:
      break
 
turtle.end_fill()
turtle.done()

python实现画五角星和螺旋线的示例

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# -*- coding:utf-8 -*-
__author__ = "zhangguodong"
__time__ = "2017.11.17"
 
import turtle
 
turtle.title("张国栋绘制螺旋线")
turtle.setup(400,400,0,0)
turtle.speed(10###设置绘制时的速度
turtle.pensize(2###设置画笔尺寸
 
for x in range(100):
  turtle.forward(2*x)
  turtle.left(90)
 
turtle.done()

python实现画五角星和螺旋线的示例

以上这篇python实现画五角星和螺旋线的示例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/Homewm/article/details/78805111

延伸 · 阅读

精彩推荐