Module: ColorMath::Adjust

Extended by:
Adjust
Included in:
Adjust
Defined in:
lib/colormath/adjust.rb

Overview

Adjust parameters of a colour

Instance Method Summary collapse

Instance Method Details

#blue(color, delta) ⇒ Object

Adjust the blue component by delta, stopping at 0 or 1



33
34
35
# File 'lib/colormath/adjust.rb', line 33

def blue(color, delta)
  RGB.new(color.red, color.green, color.blue + delta)
end

#green(color, delta) ⇒ Object

Adjust the green component by delta, stopping at 0 or 1



28
29
30
# File 'lib/colormath/adjust.rb', line 28

def green(color, delta)
  RGB.new(color.red, color.green + delta, color.blue)
end

#hue(color, delta) ⇒ Object

Rotate the hue by delta degrees in either direction



8
9
10
# File 'lib/colormath/adjust.rb', line 8

def hue(color, delta)
  HSL.new(color.hue + delta, color.saturation, color.luminance)
end

#luminance(color, delta) ⇒ Object

Adjust the luminance by delta, stopping at 0 or 1



18
19
20
# File 'lib/colormath/adjust.rb', line 18

def luminance(color, delta)
  HSL.new(color.hue, color.saturation, color.luminance + delta)
end

#red(color, delta) ⇒ Object

Adjust the red component by delta, stopping at 0 or 1



23
24
25
# File 'lib/colormath/adjust.rb', line 23

def red(color, delta)
  RGB.new(color.red + delta, color.green, color.blue)
end

#saturation(color, delta) ⇒ Object

Adjust the saturation by delta, stopping at 0 or 1



13
14
15
# File 'lib/colormath/adjust.rb', line 13

def saturation(color, delta)
  HSL.new(color.hue, color.saturation + delta, color.luminance)
end