Class: Text
- Inherits:
-
Object::TermCanvas
- Object
- Object::TermCanvas
- Text
- Defined in:
- lib/term_canvas/text.rb
Instance Attribute Summary collapse
-
#background_color ⇒ Object
readonly
Returns the value of attribute background_color.
-
#foreground_color ⇒ Object
readonly
Returns the value of attribute foreground_color.
Instance Method Summary collapse
- #draw(win) ⇒ Object
-
#initialize(x:, y:, body:, foreground_color:, background_color:) ⇒ Text
constructor
A new instance of Text.
Constructor Details
#initialize(x:, y:, body:, foreground_color:, background_color:) ⇒ Text
Returns a new instance of Text.
15 16 17 18 19 20 21 |
# File 'lib/term_canvas/text.rb', line 15 def initialize(x:, y:, body:, foreground_color:, background_color:) @x = x @y = y @body = body @foreground_color = foreground_color @background_color = background_color end |
Instance Attribute Details
#background_color ⇒ Object (readonly)
Returns the value of attribute background_color.
2 3 4 |
# File 'lib/term_canvas/text.rb', line 2 def background_color @background_color end |
#foreground_color ⇒ Object (readonly)
Returns the value of attribute foreground_color.
2 3 4 |
# File 'lib/term_canvas/text.rb', line 2 def foreground_color @foreground_color end |
Instance Method Details
#draw(win) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/term_canvas/text.rb', line 24 def draw(win) color_pair_id = BaseScreen.instance.find_or_create_color_pair( foreground_color: @foreground_color, background_color: @background_color, ).id color_pair = Curses.color_pair(color_pair_id) win.setpos(@y, @x) win.attron(color_pair) win.addstr(@body) win.attroff(color_pair) end |