Module: AsciidoctorDiagramLayout::Renderer::Scheme::ColorScheme

Included in:
AnalogousScheme, BwScheme, GoldenRatioScheme, MonochromaticScheme
Defined in:
lib/asciidoctor_diagram_layout/renderer/scheme/color_scheme.rb

Overview

Defines the duck-type contract for color scheme objects.

Every concrete scheme must include this module and override all three methods. Calling an unimplemented method raises NotImplementedError with the name of the offending class.

Examples:

Minimal implementation (black-and-white)

class BwScheme
  include ColorScheme

  FILL_COLOR = "#ffffff"

  def fill_color(_name)   = FILL_COLOR
  def gradient_end(name) = fill_color(name)
  def stroke_color(_name) = "#000000"
end

Instance Method Summary collapse

Instance Method Details

#fill_color(name) ⇒ String

Returns the base fill color for a named cell.

Parameters:

  • name (String)

    cell name, used to derive a color from its hash

Returns:

  • (String)

    hex color string (e.g. “#d4d4d4”)

Raises:

  • (NotImplementedError)


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

def fill_color(name)
  raise NotImplementedError, "#{self.class} must implement #fill_color"
end

#gradient_end(name) ⇒ String

Returns the gradient endpoint color for a named cell.

When this equals #fill_color the gradient is imperceptible, producing a visually flat fill.

Parameters:

  • name (String)

    cell name

Returns:

  • (String)

    hex color string

Raises:

  • (NotImplementedError)


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

def gradient_end(name)
  raise NotImplementedError, "#{self.class} must implement #gradient_end"
end

#stroke_color(name) ⇒ String

Returns the stroke (border) color for a named cell.

Parameters:

  • name (String)

    cell name

Returns:

  • (String)

    hex color string

Raises:

  • (NotImplementedError)


48
49
50
# File 'lib/asciidoctor_diagram_layout/renderer/scheme/color_scheme.rb', line 48

def stroke_color(name)
  raise NotImplementedError, "#{self.class} must implement #stroke_color"
end