Class: AsciidoctorDiagramLayout::Renderer::Scheme::AnalogousScheme

Inherits:
Object
  • Object
show all
Includes:
ColorScheme
Defined in:
lib/asciidoctor_diagram_layout/renderer/scheme/analogous_scheme.rb

Overview

Varies hue within a limited range around a base hue.

Produces visually harmonious palettes (warm or cool) where colors are adjacent on the color wheel.

Constant Summary collapse

GRADIENT_HUE_SHIFT =

:nodoc:

15
STROKE_LIGHTNESS =

:nodoc:

65
STROKE_SATURATION =

:nodoc:

25

Instance Method Summary collapse

Constructor Details

#initialize(base_hue, hue_range, saturation, lightness) ⇒ AnalogousScheme

Returns a new instance of AnalogousScheme.

Parameters:

  • base_hue (Integer)

    center hue (0..359)

  • hue_range (Integer)

    total spread in degrees

  • saturation (Integer)

    HSL saturation (0..100)

  • lightness (Integer)

    HSL lightness (0..100)



21
22
23
24
25
26
# File 'lib/asciidoctor_diagram_layout/renderer/scheme/analogous_scheme.rb', line 21

def initialize(base_hue, hue_range, saturation, lightness)
  @base_hue   = base_hue
  @hue_range  = hue_range
  @saturation = saturation
  @lightness  = lightness
end

Instance Method Details

#fill_color(name) ⇒ Object

:nodoc:



29
30
31
# File 'lib/asciidoctor_diagram_layout/renderer/scheme/analogous_scheme.rb', line 29

def fill_color(name)
  ColorPalette.hsl_to_hex(hue(name), @saturation, @lightness)
end

#gradient_end(name) ⇒ Object

:nodoc:



34
35
36
37
# File 'lib/asciidoctor_diagram_layout/renderer/scheme/analogous_scheme.rb', line 34

def gradient_end(name)
  ColorPalette.hsl_to_hex((hue(name) + GRADIENT_HUE_SHIFT) % ColorPalette::HUE_RANGE,
                          @saturation, @lightness)
end

#stroke_color(name) ⇒ Object

:nodoc:



40
41
42
# File 'lib/asciidoctor_diagram_layout/renderer/scheme/analogous_scheme.rb', line 40

def stroke_color(name)
  ColorPalette.hsl_to_hex(hue(name), STROKE_SATURATION, STROKE_LIGHTNESS)
end