Class: Reight::SpriteEditor::Color
- Defined in:
- lib/reight/app/sprite/color.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
Attributes inherited from Button
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(color, &clicked) ⇒ Color
constructor
A new instance of Color.
Methods inherited from Button
#click, #disabled?, #disabled_icon, #enabled?, #hover, #pressed, #pressing?, #released, #sprite
Methods included from HasHelp
Methods included from Hookable
Methods included from Activatable
#activated, #activated!, #active=, #active?
Constructor Details
#initialize(color, &clicked) ⇒ Color
Returns a new instance of Color.
6 7 8 9 10 |
# File 'lib/reight/app/sprite/color.rb', line 6 def initialize(color, &clicked) super name: color[0, 3].map {_1.to_s(16).upcase}.join, &clicked @color = color set_help name: "##{name}" end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
12 13 14 |
# File 'lib/reight/app/sprite/color.rb', line 12 def color @color end |
Instance Method Details
#draw ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/reight/app/sprite/color.rb', line 14 def draw() sp = sprite fill(*color) no_stroke blend_mode REPLACE rect 0, 0, sp.w, sp.h if active? no_fill stroke_weight 1 stroke '#000000' rect 2, 2, sp.w - 4, sp.h - 4 stroke '#ffffff' rect 1, 1, sp.w - 2, sp.h - 2 end end |