Class: Rays::Bounds

Inherits:
Object
  • Object
show all
Includes:
Comparable, Enumerable
Defined in:
lib/rays/bounds.rb

Instance Method Summary collapse

Instance Method Details

#<=>(o) ⇒ Object



87
88
89
90
91
92
93
94
# File 'lib/rays/bounds.rb', line 87

def <=>(o)
  ret = x <=> o.x; return ret if ret != 0
  ret = y <=> o.y; return ret if ret != 0
  ret = z <=> o.z; return ret if ret != 0
  ret = w <=> o.w; return ret if ret != 0
  ret = h <=> o.h; return ret if ret != 0
        d <=> o.d
end

#each(dimension = 2, &block) ⇒ Object



73
74
75
# File 'lib/rays/bounds.rb', line 73

def each(dimension = 2, &block)
  to_a(dimension).each(&block)
end

#inset_by(*args) ⇒ Object



69
70
71
# File 'lib/rays/bounds.rb', line 69

def inset_by(*args)
  dup.inset_by!(*args)
end

#left_bottomObject Also known as: lb



36
# File 'lib/rays/bounds.rb', line 36

def   left_bottom()  position        .move_by(    0, h - 1) end

#left_bottom=(*args) ⇒ Object Also known as: lb=



41
# File 'lib/rays/bounds.rb', line 41

def  left_bottom=(*args) p = Point.new(*args); self.l, self.b = p.x, p.y; lb end

#left_top=(*args) ⇒ Object Also known as: lt=



39
# File 'lib/rays/bounds.rb', line 39

def  left_top=(*args)    p = Point.new(*args); self.l, self.t = p.x, p.y; lt end

#move_by(*args) ⇒ Object



57
58
59
# File 'lib/rays/bounds.rb', line 57

def move_by(*args)
  dup.move_by!(*args)
end

#move_to(*args) ⇒ Object



53
54
55
# File 'lib/rays/bounds.rb', line 53

def move_to(*args)
  dup.move_to!(*args)
end

#resize_by(*args) ⇒ Object



65
66
67
# File 'lib/rays/bounds.rb', line 65

def resize_by(*args)
  dup.resize_by!(*args)
end

#resize_to(*args) ⇒ Object



61
62
63
# File 'lib/rays/bounds.rb', line 61

def resize_to(*args)
  dup.resize_to!(*args)
end

#right_bottomObject Also known as: rb



37
# File 'lib/rays/bounds.rb', line 37

def  right_bottom() (position + size).move_by!(  -1,    -1) end

#right_bottom=(*args) ⇒ Object Also known as: rb=



42
# File 'lib/rays/bounds.rb', line 42

def right_bottom=(*args) p = Point.new(*args); self.r, self.b = p.x, p.y; rb end

#right_topObject Also known as: rt



35
# File 'lib/rays/bounds.rb', line 35

def  right_top()     position        .move_by(w - 1,     0) end

#right_top=(*args) ⇒ Object Also known as: rt=



40
# File 'lib/rays/bounds.rb', line 40

def right_top=(*args)    p = Point.new(*args); self.r, self.t = p.x, p.y; rt end

#to_a(dimension = 2) ⇒ Object



77
78
79
80
81
82
83
84
85
# File 'lib/rays/bounds.rb', line 77

def to_a(dimension = 2)
  # TODO: return [lt, rb]
  case dimension
  when 1 then [x, w]
  when 2 then [x, y, w, h]
  when 3 then [x, y, z, w, h, d]
  else raise ArgumentError
  end
end