Module: Idml::Render::ColorHelper

Defined in:
lib/idml/render/color_helper.rb

Overview

Converts IDML color hashes to pdfrb Canvas color arrays. Centralizes the mapping so all renderers use a consistent format.

Class Method Summary collapse

Class Method Details

.to_canvas(color) ⇒ Object

Accepts a ColorResolver hash ({ model: :rgb, r:, g:, b: } or { model: :cmyk, c:, m:, y:, k: }) and returns the pdfrb Canvas array format ([:rgb, r, g, b] or [:cmyk, c, m, y, k]).



13
14
15
16
17
18
19
20
# File 'lib/idml/render/color_helper.rb', line 13

def to_canvas(color)
  return nil unless color

  case color[:model]
  when :rgb then [:rgb, color[:r], color[:g], color[:b]]
  when :cmyk then [:cmyk, color[:c], color[:m], color[:y], color[:k]]
  end
end