Class: Ea::Svg::EaEmitter::Element::BColDecoder

Inherits:
Object
  • Object
show all
Defined in:
lib/ea/svg/ea_emitter/element/bcol_decoder.rb

Overview

Decodes EA's BGR-encoded BCol/LCol integers into "#RRGGBB" hex strings. EA stores color as a Win32 COLORREF: R in low byte, G in mid byte, B in high byte.

Returns nil when bgr_int is nil OR equals -1 (EA's sentinel for "no color override" — callers fall through to a stereotype-derived default).

Constant Summary collapse

SENTINEL =
-1

Class Method Summary collapse

Class Method Details

.to_hex(bgr_int) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/ea/svg/ea_emitter/element/bcol_decoder.rb', line 17

def self.to_hex(bgr_int)
  return nil if bgr_int.nil? || bgr_int == SENTINEL

  r = bgr_int & 0xff
  g = (bgr_int >> 8) & 0xff
  b = (bgr_int >> 16) & 0xff
  format("#%02X%02X%02X", r, g, b)
end