Class: Ruby2D::Text

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby2d/text.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x = 0, y = 0, size = 20, msg = "Hello World!", font = "Arial", c = "white") ⇒ Text



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ruby2d/text.rb', line 8

def initialize(x=0, y=0, size=20, msg="Hello World!", font="Arial", c="white")
  
  if File.exists? font
    @font = font
  else
    @font = resolve_path(font)
  end
  
  @type_id = 4
  @x, @y, @size = x, y, size
  @text, @color = msg, c
  update_color(c)
  
  if defined? Ruby2D::DSL
    Ruby2D::Application.add(self)
  end
end

Instance Attribute Details

#sizeObject

Returns the value of attribute size.



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

def size
  @size
end

#textObject

Returns the value of attribute text.



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

def text
  @text
end

#xObject

Returns the value of attribute x.



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

def x
  @x
end

#yObject

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



26
27
28
29
# File 'lib/ruby2d/text.rb', line 26

def color=(c)
  @color = c
  update_color(c)
end

#removeObject



35
36
37
38
39
# File 'lib/ruby2d/text.rb', line 35

def remove
  if defined? Ruby2D::DSL
    Ruby2D::Application.remove(self)
  end
end