# L-5 MCS 260 Fri 22 Jan 2010 : turtlecolors # The script below illustrates turtle geometry # and the (r,g,b) color triangle. from math import cos, sin, pi import turtle a = 2*pi/3 # angle to draw a triangle r = 200 # radius of the enscribed circle c = 80 # radius of the colored circles # first we draw the triangle turtle.up() turtle.goto(r,0) turtle.down() turtle.goto(r*cos(a),r*sin(a)) turtle.goto(r*cos(2*a),r*sin(2*a)) turtle.goto(r,0) ans = raw_input("enter a character to continue ...") # at the corners we put primary rgb colored disks turtle.tracer(False) turtle.up() turtle.goto(r,-c) turtle.down() turtle.begin_fill() turtle.color((1.0,0.0,0.0),(1.0,0.0,0.0)) turtle.circle(c) turtle.end_fill() turtle.up() turtle.goto(r*cos(a),r*sin(a)-c) turtle.down() turtle.begin_fill() turtle.color((0.0,1.0,0.0),(0.0,1.0,0.0)) turtle.circle(c) turtle.end_fill() turtle.up() turtle.goto(r*cos(2*a),r*sin(2*a)-c) turtle.down() turtle.begin_fill() turtle.color((0.0,0.0,1.0),(0.0,0.0,1.0)) turtle.circle(c) turtle.end_fill() ans = raw_input("enter a character to continue ...") # then we draw the combinations at the edges b = pi/3 # smaller angle for 6-gon s = 100 # to put circles on edges of triangle d = 40 # radius of the secondary rgb colored disks turtle.up() turtle.goto(s*cos(b),s*sin(b)-d) turtle.down() turtle.begin_fill() turtle.color((1.0,1.0,0.0),(1.0,1.0,0.0)) turtle.circle(d) turtle.end_fill() turtle.up() turtle.goto(s*cos(a+b),s*sin(a+b)-d) turtle.down() turtle.begin_fill() turtle.color((0.0,1.0,1.0),(0.0,1.0,1.0)) turtle.circle(d) turtle.end_fill() turtle.up() turtle.goto(s*cos(2*a+b),s*sin(2*a+b)-d) turtle.down() turtle.begin_fill() turtle.color((1.0,0.0,1.0),(1.0,0.0,1.0)) turtle.circle(d) turtle.end_fill() # to prevent the turtle window from disappearing ans = raw_input('hit enter to exit ...')