Class: AsciidoctorDiagramLayout::Renderer::Scheme::GoldenRatioScheme

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

Overview

Spreads hues across the full 360-degree range using the golden ratio.

Each cell name’s Java hash determines its position on the hue circle, ensuring visually distinct colors for adjacent names.

Constant Summary collapse

GRADIENT_HUE_SHIFT =

:nodoc:

20
STROKE_LIGHTNESS =

:nodoc:

65
STROKE_SATURATION =

:nodoc:

30

Instance Method Summary collapse

Constructor Details

#initialize(saturation, lightness) ⇒ GoldenRatioScheme

Returns a new instance of GoldenRatioScheme.

Parameters:

  • saturation (Integer)

    HSL saturation (0..100)

  • lightness (Integer)

    HSL lightness (0..100)



19
20
21
22
# File 'lib/asciidoctor_diagram_layout/renderer/scheme/golden_ratio_scheme.rb', line 19

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

Instance Method Details

#fill_color(name) ⇒ Object

:nodoc:



25
26
27
# File 'lib/asciidoctor_diagram_layout/renderer/scheme/golden_ratio_scheme.rb', line 25

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

#gradient_end(name) ⇒ Object

:nodoc:



30
31
32
33
# File 'lib/asciidoctor_diagram_layout/renderer/scheme/golden_ratio_scheme.rb', line 30

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

#stroke_color(name) ⇒ Object

:nodoc:



36
37
38
# File 'lib/asciidoctor_diagram_layout/renderer/scheme/golden_ratio_scheme.rb', line 36

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