Sha256: 31b95c2e5076549f2801430498e933eb10d09e2a704de865926d932c5040cad3

Contents?: true

Size: 1 KB

Versions: 8

Compression:

Stored size: 1 KB

Contents

# encoding: utf-8
#
# Although the name of the method is <code>transparency</code>, what we are
# actually setting is the opacity for fill and stroke. So <code>0</code> means
# completely transparent and <code>1.0</code> means completely opaque
#
# You may call it providing one or two values. The first value sets fill opacity
# and the second value sets stroke opacity. If the second value is omitted fill
# and stroke will have the same opacity.
#
require File.expand_path(File.join(File.dirname(__FILE__),
                                   %w[.. example_helper]))

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
  stroke_axis

  self.line_width = 5
  fill_color "ff0000"
  fill_rectangle [0, 100], 500, 100
  
  fill_color "000000"
  stroke_color "ffffff"
  
  base_x = 100
  [[0.5, 1], 0.5, [1, 0.5]].each do |args|
    
    transparent(*args) do
      fill_circle [base_x, 100], 50
      stroke_rectangle [base_x - 20, 100], 40, 80
    end
    
    base_x += 150
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
prawn-1.0.0 manual/graphics/transparency.rb
prawn-0.15.0 manual/graphics/transparency.rb
prawn-0.14.0 manual/graphics/transparency.rb
prawn-0.13.2 manual/graphics/transparency.rb
prawn-0.13.1 manual/graphics/transparency.rb
prawn-0.13.0 manual/graphics/transparency.rb
prawn-1.0.0.rc2 manual/graphics/transparency.rb
nurettin-prawn-1.0.0.rc1 manual/graphics/transparency.rb