Class: AsciidoctorDiagramLayout::Renderer::Scheme::MonochromaticScheme

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

Overview

Varies only lightness while keeping hue and saturation fixed.

Produces a single-color palette with subtle brightness differences between cells.

Constant Summary collapse

LIGHTNESS_MIN =

:nodoc:

75
LIGHTNESS_MAX =

:nodoc:

95
GRADIENT_SHIFT =

:nodoc:

5
STROKE_LIGHTNESS =

:nodoc:

60
STROKE_SATURATION =

:nodoc:

20

Instance Method Summary collapse

Constructor Details

#initialize(hue, saturation) ⇒ MonochromaticScheme

Returns a new instance of MonochromaticScheme.

Parameters:

  • hue (Integer)

    fixed hue (0..359)

  • saturation (Integer)

    HSL saturation (0..100)



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

def initialize(hue, saturation)
  @hue        = hue
  @saturation = saturation
end

Instance Method Details

#fill_color(name) ⇒ Object

:nodoc:



27
28
29
# File 'lib/asciidoctor_diagram_layout/renderer/scheme/monochromatic_scheme.rb', line 27

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

#gradient_end(name) ⇒ Object

:nodoc:



32
33
34
35
# File 'lib/asciidoctor_diagram_layout/renderer/scheme/monochromatic_scheme.rb', line 32

def gradient_end(name)
  l = [lightness(name) + GRADIENT_SHIFT, 98].min
  ColorPalette.hsl_to_hex(@hue, @saturation, l)
end

#stroke_color(name) ⇒ Object

:nodoc:



38
39
40
# File 'lib/asciidoctor_diagram_layout/renderer/scheme/monochromatic_scheme.rb', line 38

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