Class: Reight::SpriteEditor::Color

Inherits:
Button
  • Object
show all
Defined in:
lib/reight/app/sprite/color.rb

Instance Attribute Summary collapse

Attributes inherited from Button

#icon, #label, #name

Instance Method Summary collapse

Methods inherited from Button

#click, #disabled?, #disabled_icon, #enabled?, #hover, #pressed, #pressing?, #released, #sprite

Methods included from HasHelp

#help, #name, #set_help

Methods included from Hookable

#hook

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

#colorObject (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

#drawObject



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