Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2f39454

Browse files
committed
scripts added
1 parent bd9f3c2 commit 2f39454

16 files changed

+151
-0
lines changed

‎Codes on Turtle Graphics/DashedLine.png

6.25 KB
Loading[フレーム]

‎Codes on Turtle Graphics/Dot.png

49.1 KB
Loading[フレーム]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import turtle as t
2+
3+
tim = t.Turtle()
4+
for i in range(20):
5+
tim.forward(10)
6+
tim.penup()
7+
tim.forward(10)
8+
tim.pendown()
9+
scr = t.Screen()
10+
scr.exitonclick()

‎Codes on Turtle Graphics/DrawShapes.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import turtle as t
2+
import random
3+
4+
tim = t.Turtle()
5+
ColorList = ["pink", "salmon", "pale turquoise", "lime green", "sandy brown"]
6+
7+
8+
def draw_shape(sides):
9+
for ind in range(sides):
10+
# Getting the angle of a regular polygon
11+
angle = 360 / sides
12+
tim.forward(100)
13+
tim.right(angle)
14+
15+
16+
for i in range(3, 11):
17+
tim.color(random.choice(ColorList))
18+
draw_shape(i)
19+
scr = t.Screen()
20+
scr.exitonclick()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import turtle as t
2+
import random
3+
4+
tim = t.Turtle()
5+
t.colormode(255)
6+
tim.speed("fastest")
7+
# Detecting the total number of circles
8+
for i in range(int(360 / 5)):
9+
tim.color((random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)))
10+
tim.circle(100)
11+
tim.setheading(tim.heading() + 5)
12+
scr = t.Screen()
13+
scr.exitonclick()

‎Codes on Turtle Graphics/DrawSquare.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import turtle as t
2+
3+
tim = t.Turtle()
4+
for i in range(4):
5+
tim.forward(100)
6+
tim.right(90)
7+
scr = t.Screen()
8+
scr.exitonclick()
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import turtle as t
2+
import colorgram
3+
# importing colorgram for extracting colors
4+
import random
5+
6+
RgbColor = []
7+
t.colormode(255)
8+
colors = colorgram.extract('image.jpg', 40)
9+
for color in colors:
10+
RgbColor.append((color.rgb.r, color.rgb.g, color.rgb.b))
11+
tim = t.Turtle()
12+
tim.speed("fastest") # to speed up the animation
13+
tim.penup()
14+
tim.hideturtle()
15+
tim.setheading(225)
16+
tim.forward(500)
17+
tim.setheading(0)
18+
for times in range(10):
19+
for dots in range(10):
20+
tim.dot(20, random.choice(RgbColor))
21+
tim.forward(50)
22+
tim.dot(20, random.choice(RgbColor))
23+
tim.setheading(90)
24+
tim.forward(50)
25+
if times % 2 == 0:
26+
tim.setheading(180)
27+
else:
28+
tim.setheading(0)
29+
scr = t.Screen()
30+
scr.exitonclick()

‎Codes on Turtle Graphics/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,43 @@ This is a simple figure we can create to understand basics of turtle graphics.
1818
## 2. Kaleido Spiral
1919
In this, we will draw circles and squares in continuation. Everytime we will change the radius of circle and side dimension of square to make it look like a expanding squares and circles.
2020
<img src="Kaleido-spiral.png" width="350" height="250" />
21+
22+
## 3. Draw Shapes
23+
In this, we will draw polygons (from triangles to decagons)in a continuous fashion.
24+
![](Shapes.png)
25+
26+
## 4. DrawDashedLine
27+
28+
In this, we will draw a dashed line.
29+
30+
![](DashedLine.png)
31+
32+
## 5. Draw Spirograph
33+
34+
In this , we will draw a spirograph.
35+
36+
![](Spirograph.png)
37+
38+
## 6. DrawSquare
39+
40+
In this , we will draw a square.
41+
42+
![](Square.png)
43+
44+
## 7. HirstSpotPainting
45+
46+
In this , we will make a model of the famous Hirst spot painting.
47+
48+
![](Dot.png)
49+
50+
## 8. RandomColorWalk
51+
52+
In this, we will generate a random walk using random colors.
53+
54+
![](RandomColorWalk.png)
55+
56+
## 9. RandomWalk
57+
58+
In this, we will generate a random walk using given colors.
59+
60+
![](RandomWalk.png)
33.7 KB
Loading[フレーム]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import turtle as t
2+
import random
3+
4+
ColorList = []
5+
tim = t.Turtle()
6+
t.colormode(255)
7+
tim.pensize(15)
8+
tim.speed("fastest")
9+
for i in range(300):
10+
tim.forward(30)
11+
# Choosing a random combination of colors
12+
tim.color((random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)))
13+
tim.setheading(random.choice([0, 90, 180, 270]))
14+
scr = t.Screen()
15+
scr.exitonclick()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /