Advertisement
Guest User

RubyFrac_test_01.rb

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