Module: Colir::HSLRGB::HSL

Defined in:
lib/colir/hslrgb.rb

Overview

Provides helper methods for HSL colours.

Since:

  • 0.0.1

Constant Summary collapse

H_RANGE =

The possible values for the hue.

Since:

  • 0.0.1

0..360
S_RANGE =

The possible values for the saturation.

Since:

  • 0.0.1

0..1
L_RANGE =

The possible values for the lightness.

Since:

  • 0.0.1

S_RANGE

Class Method Summary collapse

Class Method Details

.valid_hsl?(hsl) ⇒ Boolean

Performs a validation check for the hsl.

Examples:

Truthy

RGB.valid_hsl?([180, 1, 0.55]) #=> true

Falsey

RGB.valid_hsl?([180, 1.1, 0.55]) #=> false

Parameters:

  • hsl (Array<Number>)

    The HSL colour to be checked

Returns:

  • (Boolean)

    true if the given hsl colour lies within the ‘H_RANGE`, `S_RANGE`, `L_RANGE`

Since:

  • 0.0.1



75
76
77
78
# File 'lib/colir/hslrgb.rb', line 75

def self.valid_hsl?(hsl)
  valid_hue?(hsl[0]) && S_RANGE.cover?(hsl[1]) &&
    L_RANGE.cover?(hsl[2]) && (hsl.length == 3)
end