Module: ColorContrastCalc::Color::List

Defined in:
lib/color_contrast_calc/color.rb

Overview

Provide predefined lists of Color instances.

Constant Summary collapse

NAMED_COLORS =

Predefined list of named colors.

You can find the color names at www.w3.org/TR/SVG/types.html#ColorKeywords

Returns:

  • (Array<Color>)

    Named colors

keywords.map {|name, hex| Color.new(hex, name) }.freeze
WEB_SAFE_COLORS =

Predefined list of web safe colors.

Returns:

  • (Array<Color>)

    Web safe colors

generate_web_safe_colors.freeze

Class Method Summary collapse

Class Method Details

.hsl_colors(s: 100, l: 50, h_interval: 1) ⇒ Array<Color>

Return a list of colors which share the same saturation and lightness.

By default, so-called pure colors are returned.

Parameters:

  • s (defaults to: 100)

    100 [Float] Ratio of saturation in percentage

  • l (defaults to: 50)

    50 [Float] Ratio of lightness in percentage

  • h_interval (defaults to: 1)

    1 [Integer] Interval of hues in degrees. By default, the method returns 360 hues beginning from red.

Returns:

  • (Array<Color>)

    Array of colors which share the same saturation and lightness



546
547
548
# File 'lib/color_contrast_calc/color.rb', line 546

def self.hsl_colors(s: 100, l: 50, h_interval: 1)
  0.step(360, h_interval).map {|h| Color.from_hsl([h, s, l]) }.freeze
end