tips_scr_020 - spoolkitamura/nyle-doc-jp GitHub Wiki

画面(スクリーン)の背景色を指定するには?

Screenクラスを初期化する際に、画面の背景色を指定することができます。
下記のように、superメソッド呼出し時のオプションbgcolorで画面の背景色を記述してください。

[関連情報]
Nyle-Screen
Appendix3-Colors

 

  • デフォルト(白)の画面
require 'nyle'

class Screen < Nyle::Screen
  def initialize
    super   # 背景色を指定しない場合はデフォルト(白)の画面になります
  end
end

Screen.new.show_all
Nyle.main

[実行結果]


  • 背景色が青の画面
require 'nyle'

class Screen < Nyle::Screen
  def initialize
    super({bgcolor: :BLUE})   # 背景色が青の画面になります
  end
end

Screen.new.show_all
Nyle.main

[実行結果]