1, the introduction of turtle drawing
import turtle as t
2, the basic operation, a blue circle drawing
# Set the color of the circle
t.color ( 'blue')
# Start drawing
t.begin_fill ()
# 100 represents parameters redius = radius of the circle
t.circle (100)
# End drawing
t.end_fill ()
3, drawing a circle having a gradient
color_list = []
From the equator Yellow #
for G in Range (0,256):
color_list.append ((255, G, 0))
# From yellow to green
for in R & lt Range (255, -1, -1):
color_list.append ((R & lt, 255, 0))
# From green to blue
for b in the Range (0,256):
color_list.append ((0,255, b))
# From green to blue
for G in Range (255, -1, -1):
color_list.append ((0, G, 255))
# From blue to purple
for r in the Range (0,256):
color_list.append ((r, 0,255))
# From violet to red
for G in Range (255, -1, -1):
color_list.append ((255, 0, B))
4, # empty window, turtle reset state as a starting state
# (drew a blue circle, clear)
t.reset ()
# Parameters may also be replaced by a number 1-10, a slowest, 10 the fastest
t.speed ( 'fastest')
# Rgb color mode switching, 1.0: rgb Fractional mode 255: rgb integer mode
t.colormode (255)
# Set the start coordinate point (dot)
T. Goto (0,0)
# Set the start point of the drawing
start = (0, -100)
h=0
for c in color_list:
t.color©
t.begin_fill()
t.goto(start)
# Only change the direction of travel of sea turtles (angle counterclockwise)
# but does not travel, angle is the absolute degree
t.seth (h)
1 # parameters: the radius of a circle representative of the parameter represents a round score of 1536 parts
# (circle_list 1536 elements)
t.circle (100,360 / 1536)
# Get the current start coordinates, the coordinates again when reaching the stop
P = t.pos ()
H = t.heading ()
T. Goto (0,0)
Start = (P [0], P [. 1])
t.end_fill ()