Advertisement
Guest User

RubyFrac_test_02.rb

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