Advertisement
Guest User

RubyFrac_test_04.rb

a guest
Sep 18th, 2012
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.84 KB | None | 0 0
  1. require 'tk'
  2.  
  3. $point_A = [0,0]
  4. $point_B = [500,500]
  5. $rate = 1.5
  6.  
  7. def before_drawing()
  8.     $point_A = []
  9.     temp_a = $point_B[0] / $rate
  10.     temp_b = $point_B[1] / $rate
  11.     $point_A << $point_B[0] - temp_a
  12.     $point_A << $point_B[1] - temp_b
  13. end
  14.  
  15. def after_drawing()
  16.     $point_B = []
  17.     $point_B << $point_A.[0]
  18.     $point_B << $point_A.[1]
  19. end
  20.  
  21. canvas = TkCanvas.new(:width=>750, :height=>750).pack('fill' => 'both', 'expand'=>true)
  22.  
  23. rect_1 = TkcRectangle.new(canvas, $point_A, $point_B)
  24.  
  25. before_drawing()
  26. rect_2 = TkcRectangle.new(canvas, $point_A, $point_B)
  27. after_drawing()
  28.  
  29. before_drawing()
  30. rect_3 = TkcRectangle.new(canvas, $point_A, $point_B)
  31. after_drawing()
  32.  
  33. before_drawing()
  34. rect_4 = TkcRectangle.new(canvas, $point_A, $point_B)
  35. after_drawing()
  36.  
  37. before_drawing()
  38. rect_5 = TkcRectangle.new(canvas, $point_A, $point_B)
  39.  
  40. Tk.mainloop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement