Sha256: e69332b8be6f759a98c8d529a06f17d063700121f63d083fb5186203a1a02696

Contents?: true

Size: 708 Bytes

Versions: 4

Compression:

Stored size: 708 Bytes

Contents

module Chroma
  module RgbGenerator
    class FromHsvValues < Base
      # @param format [Symbol]          color format
      # @param h      [String, Numeric] hue value
      # @param s      [String, Numeric] saturation value
      # @param v      [String, Numeric] value value
      # @param a      [String, Numeric] alpha value
      def initialize(format, h, s, v, a = 1)
        s = to_percentage(s)
        v = to_percentage(v)

        @format = format || :hsv
        @hsv = ColorModes::Hsv.new(h, s, v, a)
      end

      # Generates a {ColorModes::Rgb}.
      # @return [ColorModes::Rgb]
      def generate
        [Converters::RgbConverter.convert_hsv(@hsv), @format]
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
chroma-0.2.0 lib/chroma/rgb_generator/from_hsv_values.rb
chroma-0.1.0 lib/chroma/rgb_generator/from_hsv_values.rb
chroma-0.0.1 lib/chroma/rgb_generator/from_hsv_values.rb
chroma-0.0.1.alpha.3 lib/chroma/rgb_generator/from_hsv_values.rb