Method: Color::RGB#adjust_saturation
- Defined in:
- lib/color/rgb.rb
#adjust_saturation(percent) ⇒ Object
Returns a new colour with the saturation adjusted by the specified percentage. Negative percentages will reduce the saturation; positive percentages will increase the saturation.
Color::RGB::DarkBlue.adjust_saturation(10)
Color::RGB::DarkBlue.adjust_saturation(-10)
333 334 335 336 337 338 |
# File 'lib/color/rgb.rb', line 333 def adjust_saturation(percent) percent = normalize_percent(percent) hsl = to_hsl hsl.s *= percent hsl.to_rgb end |