Skip to content

nomankarim8/Simple-turtle-Py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

logo

Recursive Star Pattern with Turtle Graphics

This project demonstrates how to use the Python turtle graphics library to draw a recursive star pattern. The pattern is drawn using a series of smaller stars within a larger star, creating a fractal-like design.

Project Structure

  • main.py: The main script containing the code to draw the recursive star pattern.

Requirements

To run this project, you'll need to have Python installed on your machine along with the turtle module. The turtle module is a standard Python library, so no additional installation is usually required. However, if you're using an environment that doesn't include turtle, you can install it using:

pip install PythonTurtle

Usage

  1. Clone the repository or download the script file.

  2. Run the script using Python:

    python main.py
  3. The program will open a window and display the recursive star pattern.

Code Explanation

The main components of the code are:

  • Setup: The turtle is initialized, and the screen background is set to black.

  • Drawing the Star: The star function is a recursive function that draws a star pattern. It takes a turtle object and a size as parameters. The function draws a star, then calls itself with a smaller size to draw smaller stars at each point.

  • Color and Speed: The turtle's color is set to yellow, and the drawing speed is set to 25 for a faster rendering.

Customization

  • Color: You can change the color of the star by modifying the a.color("yellow") line in the code.

  • Size: The size of the initial star can be adjusted by changing the argument passed to the star function.

  • Position: The starting position of the turtle can be changed by modifying the a.goto(-200, 100) line.

License

This project is open-source and available under the MIT License.