Skip to content

Commit 8c9949e

Browse files
authored
Update readme.md
1 parent da34f0e commit 8c9949e

File tree

1 file changed

+13
-1
lines changed
  • Python Projects/Intermediate Games/Spirograph

1 file changed

+13
-1
lines changed

Python Projects/Intermediate Games/Spirograph/readme.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,19 @@ Play the Video to see the Output
5454
tim.setheading(tim.heading() + size_of_gap)
5555
tim.speed(20)
5656
```
57-
4.
57+
4. The code above defines a function called draw_spirograph that takes a single argument, size_of_gap, which represents the size of the gap between the circles drawn by the turtle object named tim. Here's what the code does in detail:
58+
59+
- The for loop iterates over a range of values that represent angles in degrees. The number of iterations is determined by dividing 360 degrees (a full circle) by the size_of_gap argument, and converting the result to an integer using the int() function. This determines how many circles will be drawn in the spirograph.
60+
61+
- Inside the loop, the color of the turtle is set to a randomly generated color using the random_color() function (not shown in the code provided).
62+
63+
- The circle() method of the turtle object is called with an argument of 100, which specifies the radius of the circle to be drawn. This draws a circle of radius 100.
64+
65+
- The setheading() method is called on the turtle object, with an argument of tim.heading() + size_of_gap. This updates the direction that the turtle is facing by adding the size_of_gap value to the current heading of the turtle.
66+
67+
- Finally, the speed() method is called on the turtle object with an argument of 20. This sets the speed of the turtle to 20, which is a moderate speed for drawing the spirograph.
68+
69+
Overall, this code generates a spirograph by drawing a series of circles with random colors and slightly offsetting each subsequent circle by the size_of_gap angle. The size_of_gap argument controls the complexity and density of the spirograph.
5870

5971
## Customization
6072
You can customize the appearance of the spirograph by changing the following values in the code:

0 commit comments

Comments
 (0)