Module: Idml::Render::Blending
- Defined in:
- lib/idml/render/blending.rb
Overview
Maps an Elements::BlendingSetting to the keyword arguments that
Pdfrb::Content::Canvas#with_transparency expects. IDML stores
opacity as 0–100 (percentage); pdfrb wants 0.0–1.0 alpha. Blend
mode names line up directly with PDF BM names; unknown modes
fall back to Normal.
Constant Summary collapse
- PDF_BLEND_MODES =
%w[ Normal Multiply Screen Overlay SoftLight HardLight Darken Lighten ColorDodge ColorBurn Difference Exclusion Hue Saturation Color Luminosity ].freeze
Class Method Summary collapse
- .args_for(setting) ⇒ Object
-
.wrap(canvas, setting) ⇒ Object
Wraps the given block in
Canvas#with_transparencywhen the page item has a BlendingSetting, otherwise yields directly.
Class Method Details
.args_for(setting) ⇒ Object
17 18 19 20 21 |
# File 'lib/idml/render/blending.rb', line 17 def self.args_for(setting) return nil unless setting&.blending_setting build_args(setting.blending_setting) end |
.wrap(canvas, setting) ⇒ Object
Wraps the given block in Canvas#with_transparency when the
page item has a BlendingSetting, otherwise yields directly.
34 35 36 37 38 39 40 41 |
# File 'lib/idml/render/blending.rb', line 34 def self.wrap(canvas, setting, &) args = args_for(setting) if args canvas.with_transparency(**args, &) else yield end end |