generated from mwc/project_drawing
spiderweb with spider finished
I wrote two saparate files to draw spider and spiderweb, then I found that they work individually but cannot draw together in drawing py I tried to 1) change the variable in spider to make it align with spiderweb, not work 2) write them into one file and call their function at end, it work but does not work well Then I realized that it's position thing, when I finish drawing spiderweb, I didn't put the direction back So I tried to fix this in spiderall and it worked; Then I think it should also work in drawing project, which then works too! future project might be make the spider gif from up to down and make firework effect
This commit is contained in:
65
spider.py
Normal file
65
spider.py
Normal file
@@ -0,0 +1,65 @@
|
||||
from turtle import *
|
||||
from superturtle import *
|
||||
from superturtle.movement import *
|
||||
|
||||
from turtle import *
|
||||
|
||||
def draw_circle(radius, x, y, color=None):
|
||||
"Draw a circle with the given radius at the (x, y) position. Optionally fill with color."
|
||||
penup()
|
||||
goto(x, y - radius) # Move to the correct start point
|
||||
pendown()
|
||||
|
||||
if color:
|
||||
fillcolor(color) # Set the fill color
|
||||
begin_fill() # Start filling the circle with color
|
||||
|
||||
circle(radius) # Draw the circle
|
||||
|
||||
if color:
|
||||
end_fill() # End the filling
|
||||
|
||||
def draw_spider():
|
||||
|
||||
# Step 1: Draw the big circle (spider body) on top of the small circle
|
||||
draw_circle(60, 30, 60, color="grey")
|
||||
|
||||
# Step 2: Draw the small circle (spider head)
|
||||
draw_circle(20, 30, 0, color="black")
|
||||
|
||||
# Step 3: Draw legs on big circle
|
||||
draw_legs(60, 30, 60)
|
||||
|
||||
def draw_legs(radius, x, y):
|
||||
"Draws legs starting from the perimeter of the big circle (spider's body)"
|
||||
leg_length = 50 # Length of the legs
|
||||
pensize(4)
|
||||
|
||||
# Draw legs at equal angles from the top of the big circle
|
||||
angles = [-60, -30, 0, 30, 150, 180, 210, 240] # Angles for legs (top-left, top-right, and bottom)
|
||||
|
||||
for angle in angles:
|
||||
penup()
|
||||
goto(x, y) # Go to the center of the big circle
|
||||
setheading(angle) # Set the heading to the desired angle
|
||||
forward(radius) # Move forward to the perimeter of the big circle
|
||||
pendown()
|
||||
forward(leg_length) # Draw the leg
|
||||
penup()
|
||||
backward(leg_length) # Move back to the perimeter of the big circle
|
||||
|
||||
def draw_connection_line():
|
||||
"Draw a line from the top of the big circle (head) to the center of the small circle (body)"
|
||||
penup()
|
||||
goto(30, 400)
|
||||
pendown()
|
||||
goto(30, 120) # Draw a line to the center of the small circle (spider's body)
|
||||
penup()
|
||||
goto(0, 0)
|
||||
|
||||
# Draw the spider
|
||||
# draw_spider()
|
||||
# draw_connection_line()
|
||||
# hideturtle()
|
||||
# done()
|
||||
|
||||
Reference in New Issue
Block a user