Class: SparkleMotion::LaunchPad::Color

Inherits:
Object
  • Object
show all
Defined in:
lib/sparkle_motion/launch_pad/color.rb,
lib/sparkle_motion/launch_pad/color.rb

Overview

Color classes for the Novation Launchpad Mk 2, which supports 4 bits per color element in RGB mode.

Constant Summary collapse

BLACK =
new(0x00, 0x00, 0x00).freeze
DARK_GRAY =
new(0x07, 0x07, 0x07).freeze
LIGHT_GRAY =
new(0x27, 0x27, 0x27).freeze
WHITE =
new(0x3F, 0x3F, 0x3F).freeze
RED =
new(0x3F, 0x00, 0x00).freeze
DARK_GREEN =
new(0x00, 0x07, 0x00).freeze
GREEN =
new(0x00, 0x3F, 0x00).freeze
LIGHT_GREEN =
new(0x10, 0x4F, 0x10).freeze
BLUE =
new(0x00, 0x00, 0x3F).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(r, g, b) ⇒ Color

Returns a new instance of Color.



7
8
9
10
11
# File 'lib/sparkle_motion/launch_pad/color.rb', line 7

def initialize(r, g, b)
  @r = clamp_elem(r)
  @g = clamp_elem(g)
  @b = clamp_elem(b)
end

Instance Attribute Details

#bObject (readonly)

Returns the value of attribute b.



6
7
8
# File 'lib/sparkle_motion/launch_pad/color.rb', line 6

def b
  @b
end

#gObject (readonly)

Returns the value of attribute g.



6
7
8
# File 'lib/sparkle_motion/launch_pad/color.rb', line 6

def g
  @g
end

#rObject (readonly)

Returns the value of attribute r.



6
7
8
# File 'lib/sparkle_motion/launch_pad/color.rb', line 6

def r
  @r
end

Instance Method Details

#to_hObject



13
14
15
16
17
# File 'lib/sparkle_motion/launch_pad/color.rb', line 13

def to_h
  { r: r,
    g: g,
    b: b }
end