Method: PSD::Color.ahsb_to_color
- Defined in:
- lib/psd/color.rb
.ahsb_to_color(alpha, hue, saturation, brightness) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/psd/color.rb', line 50 def self.ahsb_to_color(alpha, hue, saturation, brightness) if saturation == 0.0 b = g = r = (255 * brightness).to_i else if brightness <= 0.5 m2 = brightness * (1 + saturation) else m2 = brightness + saturation - brightness * saturation end m1 = 2 * brightness - m2 r = hue_to_color(hue + 120, m1, m2) g = hue_to_color(hue, m1, m2) b = hue_to_color(hue - 120, m1, m2) end argb_to_color alpha, r, g, b end |