Sha256: 6d0f9a2455a85ec09e72c566fe6ed2eea4fda5503413aa43422402620d0226b6

Contents?: true

Size: 1.39 KB

Versions: 6

Compression:

Stored size: 1.39 KB

Contents

# encoding: utf-8
#
# Soft masks are user for more complex alpha channel manipulations. You can use
# arbitrary drawing functions for creation of soft masks. The resulting alpha
# channel is made of greyscale version of the drawing (luminosity channel to be
# precise). So while you can use any combination of colors for soft masks it's
# easier to use greyscales. Black will result in full transparency and white
# will make region fully opaque.
#
# Soft mask is a part of page graphic state. So if you want to apply soft mask
# only to a part of page you need to enclose drawing instructions in
# <code>save_graphics_state</code> block.

require File.expand_path(File.join(File.dirname(__FILE__),
                                   %w[.. example_helper]))

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::ManualBuilder::Example.generate(filename) do
  save_graphics_state do
    soft_mask do
      0.upto 15 do |i|
        fill_color 0, 0, 0, 100.0 / 16.0 * (15 - i)
        fill_circle [75 + i * 25, 100], 60
      end
    end

    fill_color '009ddc'
    fill_rectangle [0, 60], 600, 20

    fill_color '963d97'
    fill_rectangle [0, 80], 600, 20

    fill_color 'e03a3e'
    fill_rectangle [0, 100], 600, 20

    fill_color 'f5821f'
    fill_rectangle [0, 120], 600, 20

    fill_color 'fdb827'
    fill_rectangle [0, 140], 600, 20

    fill_color '61bb46'
    fill_rectangle [0, 160], 600, 20
  end

end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
prawn-git-2.0.1 manual/graphics/soft_masks.rb
prawn-2.0.1 manual/graphics/soft_masks.rb
prawn-2.0.0 manual/graphics/soft_masks.rb
prawn-1.3.0 manual/graphics/soft_masks.rb
prawn-1.2.1 manual/graphics/soft_masks.rb
prawn-1.1.0 manual/graphics/soft_masks.rb