Skip to content

Instantly share code, notes, and snippets.

@Uko
Created October 3, 2014 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Uko/eea47e506286b816d41d to your computer and use it in GitHub Desktop.
Save Uko/eea47e506286b816d41d to your computer and use it in GitHub Desktop.
import turtle
def circle(radius = 50, segments = 60):
turn_step = 360 / segments
segment_step = 6.28 * radius / segments
turtle.left(turn_step / 2)
for i in range(segments):
color_step = 2 * i / (segments - 1)
red = 2 - color_step
if red > 1: red = 1
blue = color_step
if blue > 1: blue = 1
turtle.pencolor(red, 0, blue)
turtle.forward(segment_step)
turtle.left(turn_step)
turtle.right(turn_step / 2)
turtle.speed(0)
turtle.pensize(50)
circle(150)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment