draw dragon ball in python

To draw a simple Dragon Ball in Python using the Turtle module, you can follow these steps:

  1. Import the turtle module
  2. Set up the turtle window and turtle object
  3. Write a function to draw a circle
  4. Call the function with appropriate parameters to draw the Dragon Ball design.

Here's the code:

main.py
import turtle

# Setup turtle window and turtle
turtle.setup(500,500)
t = turtle.Turtle()
t.speed(0)
t.hideturtle()

# Function to draw a circle
def draw_circle(x,y,r,color):
    t.penup()
    t.goto(x,y-r)
    t.pendown()
    t.fillcolor(color)
    t.begin_fill()
    t.circle(r)
    t.end_fill()

# Call the function to draw the Dragon Ball design
draw_circle(0,0,100,"red")         # Draw the outermost circle
draw_circle(0,0,90,"white")        # Draw the next circle (white)
draw_circle(0,0,65,"red")          # Draw the next circle (red)
t.penup()                          # Move to draw the four-star design
t.goto(0,20)
t.pendown()
t.fillcolor("white")
t.begin_fill()
for i in range(5):
    t.forward(18)
    t.right(144)
t.end_fill()

turtle.done()
757 chars
34 lines

The above code will draw a simple version of the Dragon Ball. You can also modify this code to draw more complex designs with different colors and patterns.

gistlibby LogSnag