Module: Moon::RenderPrimitive::Rectangular

Included in:
Moon::RenderContext, ScreenElement
Defined in:
lib/moon/packages/render_primitives/rectangular.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#hInteger

Returns:


9
10
11
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 9

def h
  @h
end

#positionMoon::Vector3

Returns:


5
6
7
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 5

def position
  @position
end

#wInteger

Returns:


7
8
9
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 7

def w
  @w
end

Instance Method Details

#align!(str, rect) ⇒ self

Parameters:

Returns:

  • (self)

151
152
153
154
155
156
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 151

def align!(str, rect)
  str.split(' ').each do |command|
    align_command!(command, rect)
  end
  self
end

#boundsMoon::Rect

Returns bounds.

Returns:


160
161
162
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 160

def bounds
  Moon::Rect.new(x, y, w, h)
end

#contains?(cx, cy) ⇒ Boolean

Returns is the position inside the rectanagle?.

Returns:

  • (Boolean)

    is the position inside the rectanagle?


172
173
174
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 172

def contains?(cx, cy)
  cx.between?(x, x2 - 1) && cy.between?(y, y2 - 1)
end

#cxInteger

Returns:


73
74
75
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 73

def cx
  x + w / 2
end

#cx=(cx) ⇒ Object

Parameters:


85
86
87
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 85

def cx=(cx)
  self.x = cx - w / 2
end

#cyInteger

Returns:


79
80
81
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 79

def cy
  y + h / 2
end

#cy=(cy) ⇒ Object

Parameters:


91
92
93
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 91

def cy=(cy)
  self.y = cy - h / 2
end

#move(x, y, z = self.z) ⇒ self

Parameters:

Returns:

  • (self)

101
102
103
104
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 101

def move(x, y, z = self.z)
  @position.set(x, y, z)
  self
end

#on_resize(*attrs) ⇒ void

This method returns an undefined value.

Parameters:

  • attrs (Symbol)

    attributes modified


108
109
110
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 108

def on_resize(*attrs)
  #
end

#resize(w, h) ⇒ self

Resizes the container provided a w and h This will trigger a ResizeEvent.

Parameters:

Returns:

  • (self)

118
119
120
121
122
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 118

def resize(w, h)
  @w, @h = w, h
  on_resize :w, :h
  self
end

#to_rectMoon::Rect

Returns rect.

Returns:


166
167
168
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 166

def to_rect
  Moon::Rect.new(x, y, w, h)
end

#xInteger

Returns:


13
14
15
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 13

def x
  @position.x
end

#x2Integer

Returns:


49
50
51
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 49

def x2
  x + w
end

#x2=(x2) ⇒ Object

Parameters:


55
56
57
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 55

def x2=(x2)
  @position.x = x2 - w
end

#x=(x) ⇒ Object

Parameters:


19
20
21
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 19

def x=(x)
  @position.x = x
end

#yInteger

Returns:


25
26
27
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 25

def y
  @position.y
end

#y2Integer

Returns:


61
62
63
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 61

def y2
  y + h
end

#y2=(y2) ⇒ Object

Parameters:


67
68
69
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 67

def y2=(y2)
  @position.y = y2 - h
end

#y=(y) ⇒ Object

Parameters:


31
32
33
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 31

def y=(y)
  @position.y = y
end

#zInteger

Returns:


37
38
39
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 37

def z
  @position.z
end

#z=(z) ⇒ Object

Parameters:


43
44
45
# File 'lib/moon/packages/render_primitives/rectangular.rb', line 43

def z=(z)
  @position.z = z
end