Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from turtle import *
- speed(10)
- scale = 30
- dot() # начало координат
- fd(100)
- rt(90)
- fd(100)
- rt(30)
- color('','orange') # color('','orange') если не брать границы
- begin_fill()
- pd()
- for i in range(4):
- fd(25*scale)
- rt(90)
- end_fill()
- pu()
- ht()
- canv = getcanvas()
- x1,y1,x2,y2 = -40*scale,-20*scale,20*scale,30*scale
- canv.update()
- k = 0
- for x in range(x1, x2, scale):
- for y in range(y1, y2, scale):
- item = canv.find_overlapping(x, y, x, y)
- if item:
- color = canv.itemcget(item,'fill')
- if color == 'orange':
- k += 1
- print(x,y,canv.find_overlapping(x, y, x, y), k)
- canv.create_oval(x-2,y-2,x+2,y+2, fill='green', outline='green')
- canv.create_text(x,y,text=k)
- canv.update()
- for x in range(x1, x2, scale):
- canv.create_line(x,y1,x,y2)
- for y in range(y1, y2, scale):
- canv.create_line(x1,y,x2,y)
- canv.update()
- print(k)
- done()
Advertisement
Add Comment
Please, Sign In to add comment