Sha256: 526f2c9607e3af88a6e2d929a23cc487a0320d7d03d76d03da1e47862449995b

Contents?: true

Size: 710 Bytes

Versions: 7

Compression:

Stored size: 710 Bytes

Contents

module Prawn::SVG::Attributes::Opacity
  def parse_opacity_attributes_and_call
    # We can't do nested opacities quite like the SVG requires, but this is close enough.
    opacity = clamp(properties.opacity.to_f, 0, 1) if properties.opacity
    fill_opacity = clamp(properties.fill_opacity.to_f, 0, 1) if properties.fill_opacity
    stroke_opacity = clamp(properties.stroke_opacity.to_f, 0, 1) if properties.stroke_opacity

    if opacity || fill_opacity || stroke_opacity
      state.fill_opacity *= [opacity || 1, fill_opacity || 1].min
      state.stroke_opacity *= [opacity || 1, stroke_opacity || 1].min

      add_call_and_enter 'transparent', state.fill_opacity, state.stroke_opacity
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
prawn-svg-0.34.2 lib/prawn/svg/attributes/opacity.rb
prawn-svg-0.34.1 lib/prawn/svg/attributes/opacity.rb
prawn-svg-0.34.0 lib/prawn/svg/attributes/opacity.rb
prawn-svg-0.33.0 lib/prawn/svg/attributes/opacity.rb
prawn-svg-0.32.0 lib/prawn/svg/attributes/opacity.rb
prawn-svg-0.31.0 lib/prawn/svg/attributes/opacity.rb
prawn-svg-0.30.0 lib/prawn/svg/attributes/opacity.rb