Class: Ruby2D::Text
- Inherits:
-
Object
- Object
- Ruby2D::Text
- Defined in:
- lib/ruby2d/text.rb
Instance Attribute Summary collapse
-
#size ⇒ Object
Returns the value of attribute size.
-
#text ⇒ Object
Returns the value of attribute text.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #color=(c) ⇒ Object
-
#initialize(x = 0, y = 0, size = 20, text = "Hello World!", font = "Arial", c = "white") ⇒ Text
constructor
A new instance of Text.
- #remove ⇒ Object
Constructor Details
#initialize(x = 0, y = 0, size = 20, text = "Hello World!", font = "Arial", c = "white") ⇒ Text
Returns a new instance of Text.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ruby2d/text.rb', line 8 def initialize(x=0, y=0, size=20, text="Hello World!", font="Arial", c="white") if font.include? '.' unless File.exists? font raise Error, "Cannot find font file!" else @font = font end else @font = resolve_path(font) end @type_id = 4 @x, @y, @size = x, y, size @text, @color = text, c update_color(c) if defined? Ruby2D::DSL Ruby2D::Application.add(self) end end |
Instance Attribute Details
#size ⇒ Object
Returns the value of attribute size.
6 7 8 |
# File 'lib/ruby2d/text.rb', line 6 def size @size end |
#text ⇒ Object
Returns the value of attribute text.
6 7 8 |
# File 'lib/ruby2d/text.rb', line 6 def text @text end |
#x ⇒ Object
Returns the value of attribute x.
6 7 8 |
# File 'lib/ruby2d/text.rb', line 6 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
6 7 8 |
# File 'lib/ruby2d/text.rb', line 6 def y @y end |
Instance Method Details
#color=(c) ⇒ Object
29 30 31 32 |
# File 'lib/ruby2d/text.rb', line 29 def color=(c) @color = c update_color(c) end |
#remove ⇒ Object
38 39 40 41 42 |
# File 'lib/ruby2d/text.rb', line 38 def remove if defined? Ruby2D::DSL Ruby2D::Application.remove(self) end end |