from turtle import * |
ht() |
tracer( 0 ) |
x1 = - 400 |
y1 = - 400 |
宽 = 200 |
高 = 200 |
colorall = [ 'red' , 'orange' , 'yellow' , 'green' , 'cyan' , 'blue' , 'purple' ] |
n = 0 |
def brick(mycolor): |
fillcolor(mycolor) |
pu() |
goto(x1,y1) |
pd() |
begin_fill() |
for i in range ( 2 ): |
fd(宽) |
lt( 90 ) |
fd(高) |
lt( 90 ) |
end_fill() |
update() |
brick(colorall[n]) |
def draw(x,y): |
if x>x1 and x<x1 + 宽 and y>y1 and y<y1 + 高: |
global n |
n = n + 1 |
if n> = len (colorall): |
n = 0 |
brick(colorall[n]) |
else : |
pu() |
goto(x,y) |
pd() |
dot( 20 ,colorall[n]) |
onscreenclick(draw) |
done() |