Class: Ea::Diagram::StyleParser

Inherits:
Object
  • Object
show all
Defined in:
lib/ea/diagram/style_parser.rb

Constant Summary collapse

DEFAULT_FILL_COLOR =

EA's default fill color (light yellow) used when an EA color integer is zero / unset.

"#FFFFCC"

Instance Method Summary collapse

Instance Method Details

#color_from_ea_color(ea_color) ⇒ String

Convert EA color integer (BGR) to hex color string.

EA stores colors as BGR integers in DiagramObject.style strings (e.g. "BCol=16764159"). A zero value means "use the EA default".

Parameters:

  • ea_color (Integer)

    EA BGR color value

Returns:

  • (String)

    Hex color string (e.g. "#FFFFCC")



31
32
33
34
35
36
37
38
39
# File 'lib/ea/diagram/style_parser.rb', line 31

def color_from_ea_color(ea_color)
  return DEFAULT_FILL_COLOR if ea_color.zero?

  b = (ea_color & 0xFF0000) >> 16
  g = (ea_color & 0x00FF00) >> 8
  r = ea_color & 0x0000FF

  format("#%02X%02X%02X", r, g, b)
end