Class: Hokusai::Commands::Text

Inherits:
Base
  • Object
show all
Defined in:
ui/src/hokusai/commands/text.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#after_draw, draw, #draw, on_draw

Constructor Details

#initialize(content, x, y) ⇒ Text

Returns a new instance of Text.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'ui/src/hokusai/commands/text.rb', line 8

def initialize(content, x, y)
  @content = content
  @x = x.to_f
  @y = y.to_f
  @color = Color.new(0, 0, 0, 255)
  @padding = Padding.new(0.0, 0.0, 0.0, 0.0)
  @size = 17
  @wrap = false
  @font = nil
  @static = true
  @bold = false
  @italic = false
  @line_height = 0.0
end

Instance Attribute Details

#boldObject

Returns the value of attribute bold.



3
4
5
# File 'ui/src/hokusai/commands/text.rb', line 3

def bold
  @bold
end

#colorObject

Returns the value of attribute color.



3
4
5
# File 'ui/src/hokusai/commands/text.rb', line 3

def color
  @color
end

#contentObject

Returns the value of attribute content.



3
4
5
# File 'ui/src/hokusai/commands/text.rb', line 3

def content
  @content
end

#fontObject

Returns the value of attribute font.



3
4
5
# File 'ui/src/hokusai/commands/text.rb', line 3

def font
  @font
end

#italicObject

Returns the value of attribute italic.



3
4
5
# File 'ui/src/hokusai/commands/text.rb', line 3

def italic
  @italic
end

#line_heightObject

Returns the value of attribute line_height.



3
4
5
# File 'ui/src/hokusai/commands/text.rb', line 3

def line_height
  @line_height
end

#paddingObject

Returns the value of attribute padding.



3
4
5
# File 'ui/src/hokusai/commands/text.rb', line 3

def padding
  @padding
end

#sizeObject

Returns the value of attribute size.



3
4
5
# File 'ui/src/hokusai/commands/text.rb', line 3

def size
  @size
end

#staticObject

Returns the value of attribute static.



3
4
5
# File 'ui/src/hokusai/commands/text.rb', line 3

def static
  @static
end

#wrapObject (readonly)

Returns the value of attribute wrap.



3
4
5
# File 'ui/src/hokusai/commands/text.rb', line 3

def wrap
  @wrap
end

#xObject (readonly)

Returns the value of attribute x.



3
4
5
# File 'ui/src/hokusai/commands/text.rb', line 3

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



3
4
5
# File 'ui/src/hokusai/commands/text.rb', line 3

def y
  @y
end

Instance Method Details

#dynamic=(value) ⇒ Object



43
44
45
# File 'ui/src/hokusai/commands/text.rb', line 43

def dynamic=(value)
  @static = !value
end

#hashObject



23
24
25
# File 'ui/src/hokusai/commands/text.rb', line 23

def hash
  [self.class, content, color.hash, padding.hash, size, font, wrap].hash
end

#padding?Boolean

Returns:

  • (Boolean)


86
87
88
89
90
# File 'ui/src/hokusai/commands/text.rb', line 86

def padding?
  [padding.t, padding.r, padding.b, padding.l].any? do |p|
    p != 0.0
  end
end