Sha256: 615a38e03b262c753ab27b7750a673e3c54b3e1c4d527d0eac2ba034f6e61dba

Contents?: true

Size: 699 Bytes

Versions: 2

Compression:

Stored size: 699 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.
    fill_opacity = stroke_opacity = clamp(attributes['opacity'].to_f, 0, 1) if attributes['opacity']
    fill_opacity = clamp(attributes['fill-opacity'].to_f, 0, 1) if attributes['fill-opacity']
    stroke_opacity = clamp(attributes['stroke-opacity'].to_f, 0, 1) if attributes['stroke-opacity']

    if fill_opacity || stroke_opacity
      state.fill_opacity *= fill_opacity || 1
      state.stroke_opacity *= stroke_opacity || 1

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
prawn-svg-0.23.1 lib/prawn/svg/attributes/opacity.rb
prawn-svg-0.23.0 lib/prawn/svg/attributes/opacity.rb