Git Product home page Git Product logo

spirograph's Introduction

Spirograph ๐ŸŒ€

๐ŸŒˆ Welcome to the Begginer-friendly Spirograph Drawing project

Crafted and taught by Shreya Malogi! ๐ŸŒ

GitHub stars

Project Details: ๐ŸŽจ๐Ÿข๐Ÿ“…โœ๏ธ

  • Functionality: Creates vibrant and mesmerizing spirograph drawings using Python's Turtle module.
  • Tech Stack: Python, turtle, random
  • Author: @shreyamalogi
  • Year of Project: 2021

Table of Contents ๐Ÿ“š

  1. Introduction
  2. Prerequisites
  3. Installation
  4. Running the Script
  5. Understanding the Code
  6. Customizing Your Spirograph
  7. Contribution
  8. License

Introduction ๐ŸŽจ

Welcome to Spirograph Drawing! This Python script allows you to create vibrant and mesmerizing spirograph drawings using the Turtle module. Get ready to unleash your creativity with a few lines of code! ๐ŸŒ€๐ŸŒˆ

Prerequisites ๐Ÿ› ๏ธ

Before you dive into the world of spirographs, make sure you have Python installed on your machine. If not, you can download it here.

Installation ๐Ÿข

No additional modules are required for this script. Just make sure you have Python installed.

Running the Script โ–ถ๏ธ

  1. Open the script in your favorite Python environment.
  2. Run the script. This will launch the Turtle graphics window.

Understanding the Code ๐Ÿค“

Let's break down the provided Python code for the Spirograph Drawing script:

import turtle as t
import random

myrtle = t.Turtle()
t.colormode(255)

def random_color():
    r = random.randint(0, 255)
    g = random.randint(0, 255)
    b = random.randint(0, 255)
    color = (r, g, b)
    return color

def draw_spirograph(size_of_gap):
    for _ in range(int(360 / size_of_gap)):
        myrtle.color(random_color())
        myrtle.circle(100)
        myrtle.setheading(myrtle.heading() + size_of_gap)

draw_spirograph(5)

Code Explanation:

  1. Importing Libraries:

    import turtle as t
    import random
    • turtle is a module in Python that provides a way to create simple graphics.
    • random is a module that provides functions for generating random numbers.
  2. Creating a Turtle:

    myrtle = t.Turtle()
    t.colormode(255)
    • myrtle is an instance of the Turtle class, which is used for drawing.
    • t.colormode(255) sets the color mode to use RGB values ranging from 0 to 255.
  3. Generating Random Colors:

    def random_color():
        r = random.randint(0, 255)
        g = random.randint(0, 255)
        b = random.randint(0, 255)
        color = (r, g, b)
        return color
    • The random_color function generates a random RGB color and returns it as a tuple.
  4. Drawing Spirograph:

    def draw_spirograph(size_of_gap):
        for _ in range(int(360 / size_of_gap)):
            myrtle.color(random_color())
            myrtle.circle(100)
            myrtle.setheading(myrtle.heading() + size_of_gap)
    • The draw_spirograph function uses a loop to draw circles in a spirograph pattern.
    • myrtle.color(random_color()) sets the turtle's color to a random color.
    • myrtle.circle(100) draws a circle with a radius of 100 units.
    • myrtle.setheading(myrtle.heading() + size_of_gap) changes the heading of the turtle, creating the spirograph effect.
  5. Executing the Drawing:

    draw_spirograph(5)
    • This line calls the draw_spirograph function with a size_of_gap of 5, determining the gap between each circle in the spirograph.

The script, when executed, will create a visually appealing spirograph drawing with randomized colors. Adjusting the parameters can lead to various spirograph patterns.

Customizing Your Spirograph ๐ŸŽจ

Feel free to experiment with the script! Adjust the size_of_gap parameter in the draw_spirograph function to change the gap between each circle in the spirograph. You can also modify colors, circle radii, and other parameters to create various spirograph patterns.

Contribution- Show Your Support (Star This) โญ๐ŸŒŸ๐Ÿ“œโœจ

Enjoying the magic of spirographs? Contribute to this creative journey and make it even more enchanting. Don't forget to star the project! โญ๐ŸŒŸ

License โš–๏ธ

This project is enchanted under the spell of the MIT License. Share the magic responsibly!

MIT License

Copyright (c) 2021 Shreya Malogi

Stay Enchanted! ๐ŸŒ๐Ÿ’™

spirograph's People

Contributors

shreyamalogi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.