Module: Sai::Conversion::RGB::ColorSpace Private
- Defined in:
- lib/sai/conversion/rgb/color_space.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Convert colors between different color space formats
Class Method Summary collapse
-
.hsv_to_rgb(hue, saturation, value) ⇒ Array<Integer>
private
Convert HSV values to RGB.
-
.resolve(color) ⇒ Array<Integer>
private
Convert a color value to RGB components.
Class Method Details
.hsv_to_rgb(hue, saturation, value) ⇒ Array<Integer>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Convert HSV values to RGB
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/sai/conversion/rgb/color_space.rb', line 29 def hsv_to_rgb(hue, saturation, value) hue_sector = (hue / 60.0).floor.to_i hue_remainder = (hue / 60.0) - hue_sector components = calculate_hsv_components(value, saturation, hue_remainder) primary, secondary, tertiary = *components return [0, 0, 0] unless primary && secondary && tertiary rgb = select_rgb_values(hue_sector, value, primary, secondary, tertiary) normalize_rgb(rgb) end |
.resolve(color) ⇒ Array<Integer>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Convert a color value to RGB components
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/sai/conversion/rgb/color_space.rb', line 54 def resolve(color) case color when Array then validate_rgb(color) when /^#?([A-Fa-f0-9]{6})$/ hex_to_rgb( Regexp.last_match(1) # steep:ignore ArgumentTypeMismatch ) when String, Symbol then named_to_rgb(color.to_s.downcase) else raise ArgumentError, "Invalid color format: #{color}" end end |