boris-vlasenko

график области

Jan 28th, 2018
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1.  
  2. from tkinter import *
  3. root = Tk()
  4.  
  5. canv = Canvas(bg='lightblue')
  6. canv.pack(fill=BOTH, expand=1)
  7. root.geometry('600x600')
  8. def f(x,y):
  9.     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)
  10.  
  11. def f2(x,y):
  12.     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)
  13.  
  14. x0 = 300
  15. y0 = 300
  16. r = 2
  17. m = 50
  18. for xx in range(-300,300):
  19.     for yy in range(-300,300):
  20.         color = 'lightgray'
  21.         x = xx/m
  22.         y = -yy/m
  23.         if f2(x,y):
  24.             color = 'orange'
  25.             canv.create_oval(x0+xx-r,y0+yy-r,x0+xx+r,y0+yy+r,fill=color,outline='')
  26. canv.create_line(0,y0,600,y0)
  27. canv.create_line(x0,0,x0,600)
  28.  
  29.  
  30. mainloop()
Advertisement
Add Comment
Please, Sign In to add comment