Class: Ruby2D::Text
- Inherits:
-
Object
- Object
- Ruby2D::Text
- Defined in:
- lib/ruby2d/text.rb,
ext/ruby2d/ruby2d-opal.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#data ⇒ Object
Returns the value of attribute data.
-
#font ⇒ Object
readonly
Returns the value of attribute font.
-
#size ⇒ Object
readonly
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
- #add ⇒ Object
- #init ⇒ Object
-
#initialize(x = 0, y = 0, text = "Hello World!", size = 20, font = nil, c = "white") ⇒ Text
constructor
A new instance of Text.
- #remove ⇒ Object
Constructor Details
#initialize(x = 0, y = 0, text = "Hello World!", size = 20, font = nil, c = "white") ⇒ Text
Returns a new instance of Text.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ruby2d/text.rb', line 9 def initialize(x=0, y=0, text="Hello World!", size=20, font=nil, c="white") # if File.exists? font @font = font # else # @font = resolve_path(font) # end @type_id = 5 @x, @y, @size = x, y, size @text = text @color = Color.new(c) init add end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
7 8 9 |
# File 'lib/ruby2d/text.rb', line 7 def color @color end |
#data ⇒ Object
Returns the value of attribute data.
6 7 8 |
# File 'lib/ruby2d/text.rb', line 6 def data @data end |
#font ⇒ Object (readonly)
Returns the value of attribute font.
7 8 9 |
# File 'lib/ruby2d/text.rb', line 7 def font @font end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
7 8 9 |
# File 'lib/ruby2d/text.rb', line 7 def size @size end |
#text ⇒ Object
Returns the value of attribute text.
7 8 9 |
# File 'lib/ruby2d/text.rb', line 7 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
#add ⇒ Object
29 30 31 32 33 |
# File 'lib/ruby2d/text.rb', line 29 def add if Module.const_defined? :DSL Application.add(self) end end |
#init ⇒ Object
147 148 149 |
# File 'ext/ruby2d/ruby2d-opal.rb', line 147 def init `#{self}.data = S2D.CreateText(#{self}.font, #{self}.text, #{self}.size);` end |
#remove ⇒ Object
35 36 37 38 39 |
# File 'lib/ruby2d/text.rb', line 35 def remove if Module.const_defined? :DSL Application.remove(self) end end |