Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from turtle import Turtle
- import math
- turtle = Turtle()
- turtle.shape("turtle")
- def draw_circle(radius):
- draw_arc(radius, 360)
- def draw_arc(radius, angle):
- circle_length = angle / 180 * math.pi * radius
- max_segment_length = 2
- segments = int(max(1, circle_length // max_segment_length))
- segment_length = circle_length / segments
- segment_rotation = angle / segments
- for i in range(segments):
- turtle.forward(segment_length)
- turtle.left(segment_rotation)
- def jump_forward(distance):
- turtle.penup()
- turtle.forward(distance)
- turtle.pendown()
- def draw_gear(hole_radius, ring_width, pips_height, pips_count, pip_boldness):
- jump_forward(hole_radius)
- turtle.left(90)
- draw_circle(hole_radius)
- turtle.right(90)
- jump_forward(ring_width)
- inner_radius = ring_width + hole_radius
- outter_radius = inner_radius + pips_height
- segment_arc = 360 / pips_count
- pip_arc = pip_boldness * segment_arc
- hole_arc = segment_arc - pip_arc
- turtle.left(90)
- for i in range(pips_count):
- draw_arc(inner_radius, hole_arc)
- turtle.right(90)
- turtle.forward(pips_height)
- turtle.left(90)
- draw_arc(outter_radius, pip_arc)
- turtle.left(90)
- turtle.forward(pips_height)
- turtle.right(90)
- turtle.penup()
- turtle.goto(0, 0)
- turtle.pendown()
- draw_gear(20, 40, 15, 8, 0.5)
- turtle.penup()
- turtle.goto(120, -100)
- turtle.pendown()
- draw_gear(10, 50, 5, 16, 0.8)
- turtle.penup()
- turtle.goto(70, 90)
- turtle.pendown()
- draw_gear(16, 4, 10, 9, 0.2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement