mirror of
https://github.com/metafy-social/python-scripts.git
synced 2025-03-15 18:19:52 +00:00
Turtle Graphics
This commit is contained in:
parent
421bf9468e
commit
51549f6a8b
5
scripts/turtle_graphics/README.md
Normal file
5
scripts/turtle_graphics/README.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Turtle Graphics
|
||||||
|
|
||||||
|
The turtle module provides an environment in which turtles move around on a 2-dimensional grid. Turtles have a position, heading (the direction the turtle is facing) and a variety of possible states (turtles can draw lines of a particular colour when they move or leave no trace) and actions (turn left or right; move forward or backward.
|
||||||
|
|
||||||
|
We can create amazing graphics using turtle and colorsys module.
|
2
scripts/turtle_graphics/requirements.txt.txt
Normal file
2
scripts/turtle_graphics/requirements.txt.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
turtle
|
||||||
|
colorsys
|
21
scripts/turtle_graphics/turtle_graphics.py
Normal file
21
scripts/turtle_graphics/turtle_graphics.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import turtle as tur
|
||||||
|
import colorsys as cs
|
||||||
|
|
||||||
|
tur.setup(800,800)
|
||||||
|
tur.speed(0)
|
||||||
|
tur.tracer(10)
|
||||||
|
tur.width(2)
|
||||||
|
tur.bgcolor("black")
|
||||||
|
|
||||||
|
for j in range(25):
|
||||||
|
for i in range(15):
|
||||||
|
tur.color(cs.hsv_to_rgb(i/15,j/25,1))
|
||||||
|
tur.right(90)
|
||||||
|
tur.circle(200-j*4,90)
|
||||||
|
tur.left(90)
|
||||||
|
tur.circle(200-j*4,90)
|
||||||
|
tur.right(180)
|
||||||
|
tur.circle(50,24)
|
||||||
|
|
||||||
|
tur.hideturtle()
|
||||||
|
tur.done()
|
Loading…
x
Reference in New Issue
Block a user