Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- root = Tk()
- canv = Canvas(bg='lightblue')
- canv.pack(fill=BOTH, expand=1)
- root.geometry('600x600')
- def f(x,y):
- return (x > 0) and (x**2 + y**2 <4) or (x<0 and y >0 and y < x+2) or (x<0 and y < 0 and x > -2 and y > -2)
- def f2(x,y):
- return (y > 0) and (x > 0) and (y < 1.5*x and y > 3*x-4) or (x<0) and (y<0) and (y > 1.5*x) and (y < 3*x+4)
- x0 = 300
- y0 = 300
- r = 2
- m = 50
- for xx in range(-300,300):
- for yy in range(-300,300):
- color = 'lightgray'
- x = xx/m
- y = -yy/m
- if f2(x,y):
- color = 'orange'
- canv.create_oval(x0+xx-r,y0+yy-r,x0+xx+r,y0+yy+r,fill=color,outline='')
- canv.create_line(0,y0,600,y0)
- canv.create_line(x0,0,x0,600)
- mainloop()
Advertisement
Add Comment
Please, Sign In to add comment