Class: Shoes::Swt::LinkSegment::Region

Inherits:
Object
  • Object
show all
Defined in:
shoes-swt/lib/shoes/swt/link_segment.rb

Instance Method Summary collapse

Constructor Details

#initialize(start_x, start_y, end_x, end_y) ⇒ Region

Returns a new instance of Region.



92
93
94
95
96
97
# File 'shoes-swt/lib/shoes/swt/link_segment.rb', line 92

def initialize(start_x, start_y, end_x, end_y)
  @start_x = start_x
  @start_y = start_y
  @end_x = end_x
  @end_y = end_y
end

Instance Method Details

#in_bounds?(x, y) ⇒ Boolean

Returns:

  • (Boolean)


107
108
109
# File 'shoes-swt/lib/shoes/swt/link_segment.rb', line 107

def in_bounds?(x, y)
  (@start_x..@end_x).cover?(x) && (@start_y..@end_y).cover?(y)
end

#offset_by!(left, top) ⇒ Object



99
100
101
102
103
104
105
# File 'shoes-swt/lib/shoes/swt/link_segment.rb', line 99

def offset_by!(left, top)
  @start_x += left
  @end_x   += left

  @start_y += top
  @end_y   += top
end