Class: TermCanvas::Rect
Instance Attribute Summary collapse
-
#background_color ⇒ Object
readonly
Returns the value of attribute background_color.
Attributes inherited from Object
Instance Method Summary collapse
- #draw(win) ⇒ Object
- #foreground_color ⇒ Object
-
#initialize(x:, y:, width:, height:, background_color:) ⇒ Rect
constructor
A new instance of Rect.
Methods inherited from Object
#position_offset, #position_override, #set_index
Constructor Details
#initialize(x:, y:, width:, height:, background_color:) ⇒ Rect
Returns a new instance of Rect.
10 11 12 13 14 15 16 |
# File 'lib/term_canvas/rect.rb', line 10 def initialize(x:, y:, width:, height:, background_color:) @x = x @y = y @width = width @height = height @background_color = background_color end |
Instance Attribute Details
#background_color ⇒ Object (readonly)
Returns the value of attribute background_color.
3 4 5 |
# File 'lib/term_canvas/rect.rb', line 3 def background_color @background_color end |
Instance Method Details
#draw(win) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/term_canvas/rect.rb', line 23 def draw(win) color_pair_id = TermCanvas::BaseScreen.instance.find_or_create_color_pair( background_color: @background_color, ).id color_pair = Curses.color_pair(color_pair_id) win.setpos(@y, @x) win.attron(color_pair) @height.times do win.addstr(" " * @width) win.setpos(win.cury + 1, @x) end win.attroff(color_pair) end |
#foreground_color ⇒ Object
18 19 20 |
# File 'lib/term_canvas/rect.rb', line 18 def foreground_color nil end |