Module: Ruby2D::Renderable

Included in:
Circle, Image, Line, Quad, Sprite, Text, Tileset, Triangle
Defined in:
lib/ruby2d/renderable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#colorObject Also known as: colour

Returns the value of attribute color.



6
7
8
# File 'lib/ruby2d/renderable.rb', line 6

def color
  @color
end

#heightObject (readonly)

Returns the value of attribute height.



6
7
8
# File 'lib/ruby2d/renderable.rb', line 6

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



6
7
8
# File 'lib/ruby2d/renderable.rb', line 6

def width
  @width
end

#xObject (readonly)

Returns the value of attribute x.



6
7
8
# File 'lib/ruby2d/renderable.rb', line 6

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



6
7
8
# File 'lib/ruby2d/renderable.rb', line 6

def y
  @y
end

#zObject

Returns the value of attribute z.



6
7
8
# File 'lib/ruby2d/renderable.rb', line 6

def z
  @z
end

Instance Method Details

#aObject



38
# File 'lib/ruby2d/renderable.rb', line 38

def a; self.color.a end

#a=(c) ⇒ Object



42
# File 'lib/ruby2d/renderable.rb', line 42

def a=(c); self.color.a = c end

#addObject

Add the object to the window



16
17
18
# File 'lib/ruby2d/renderable.rb', line 16

def add
  Window.add(self)
end

#bObject



37
# File 'lib/ruby2d/renderable.rb', line 37

def b; self.color.b end

#b=(c) ⇒ Object



41
# File 'lib/ruby2d/renderable.rb', line 41

def b=(c); self.color.b = c end

#contains?(x, y) ⇒ Boolean

Add a contains method stub

Returns:

  • (Boolean)


47
48
49
# File 'lib/ruby2d/renderable.rb', line 47

def contains?(x, y)
  x >= @x && x <= (@x + @width) && y >= @y && y <= (@y + @height)
end

#gObject



36
# File 'lib/ruby2d/renderable.rb', line 36

def g; self.color.g end

#g=(c) ⇒ Object



40
# File 'lib/ruby2d/renderable.rb', line 40

def g=(c); self.color.g = c end

#opacityObject



43
# File 'lib/ruby2d/renderable.rb', line 43

def opacity; self.color.opacity end

#opacity=(val) ⇒ Object



44
# File 'lib/ruby2d/renderable.rb', line 44

def opacity=(val); self.color.opacity = val end

#rObject

Allow shortcuts for setting color values



35
# File 'lib/ruby2d/renderable.rb', line 35

def r; self.color.r end

#r=(c) ⇒ Object



39
# File 'lib/ruby2d/renderable.rb', line 39

def r=(c); self.color.r = c end

#removeObject

Remove the object from the window



21
22
23
# File 'lib/ruby2d/renderable.rb', line 21

def remove
  Window.remove(self)
end