class TermCanvas::Rect
Attributes
background_color[R]
Public Class Methods
new(x:, y:, width:, height:, background_color:)
click to toggle source
@param x [Integer] Horizontal position of the object. @param y [Integer] Vertical position of the object. @param background_color
[Hash] :r Red element of color of background. @param background_color
[Hash] :g Green element of color of background. @param background_color
[Hash] :b Blue element of color of background.
# 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
Public Instance Methods
draw(win)
click to toggle source
@param win [Curses::Window] Window to draw
# 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()
click to toggle source
# File lib/term_canvas/rect.rb, line 18 def foreground_color nil end