### Home Classes Methods

### In Files

- lib/prawn/graphics/transparency.rb

### Methods

- #transparent

### Class/Module Index

Quicksearch

- Prawn
- Prawn::Configurable
- Prawn::Document
- Prawn::Document::BoundingBox
- Prawn::Document::ColumnBox
- Prawn::Document::GraphicsState
- Prawn::Document::Grid
- Prawn::Document::GridBox
- Prawn::Document::Internals
- Prawn::Document::Security
- Prawn::Document::Snapshot
- Prawn::Encoding
- Prawn::Errors
- Prawn::Font
- Prawn::Font::AFM
- Prawn::Font::DFont
- Prawn::Font::TTF
- Prawn::FontMetricCache
- Prawn::Graphics
- Prawn::Graphics::CapStyle
- Prawn::Graphics::Color
- Prawn::Graphics::Dash
- Prawn::Graphics::JoinStyle
- Prawn::Graphics::Patterns
- Prawn::Graphics::Transformation
- Prawn::Graphics::Transparency
- Prawn::ImageHandler
- Prawn::Images
- Prawn::Images::Image
- Prawn::Images::JPG
- Prawn::Images::PNG
- Prawn::Measurements
- Prawn::SoftMask
- Prawn::Stamp
- Prawn::SynchronizedCache
- Prawn::Table
- Prawn::Table::Cell
- Prawn::Table::Cell::Image
- Prawn::Table::Cell::InTable
- Prawn::Table::Cell::SpanDummy
- Prawn::Table::Cell::Subtable
- Prawn::Table::Cell::Text
- Prawn::Table::Cells
- Prawn::Table::ColumnWidthCalculator
- Prawn::Text
- Prawn::Text::Box
- Prawn::Text::Formatted
- Prawn::Text::Formatted::Box
- Prawn::Text::Formatted::Fragment
- Prawn::Text::Formatted::Parser
- Prawn::ThreadLocalCache
- PDF
- PDF::Core
- PDF::Core::Reference
- PDF::Core::Stream
- Arcfour
- Numeric

No matching classes.

# Prawn::Graphics::Transparency

The Prawn::Transparency module is used to place transparent content on the page. It has the capacity for separate transparency values for stroked content and all other content.

Example:

    # both the fill and stroke will be at 50% opacity
    pdf.transparent(0.5) do
      pdf.text("hello world")
      pdf.fill_and_stroke_circle([x, y], 25)
    end

    # the fill will be at 50% opacity, but the stroke will
    # be at 75% opacity
    pdf.transparent(0.5, 0.75) do
      pdf.text("hello world")
      pdf.fill_and_stroke_circle([x, y], 25)
    end

### Public Instance Methods

transparent(opacity, stroke_opacity=opacity, &block) click to toggle source

Sets the `opacity` and `stroke_opacity` for all the content within the `block` If `stroke_opacity` is not provided, then it takes on the same value as `opacity`

Valid ranges for both paramters are 0.0 to 1.0

Example:

    # both the fill and stroke will be at 50% opacity
    pdf.transparent(0.5) do
      pdf.text("hello world")
      pdf.fill_and_stroke_circle([x, y], 25)
    end

    # the fill will be at 50% opacity, but the stroke will
    # be at 75% opacity
    pdf.transparent(0.5, 0.75) do
      pdf.text("hello world")
      pdf.fill_and_stroke_circle([x, y], 25)
    end

    # File lib/prawn/graphics/transparency.rb, line 55
    def transparent(opacity, stroke_opacity=opacity, &block)
      min_version(1.4)

      opacity        = [[opacity, 0.0].max, 1.0].min
      stroke_opacity = [[stroke_opacity, 0.0].max, 1.0].min

      save_graphics_state
      add_content "/#{opacity_dictionary_name(opacity, stroke_opacity)} gs"
      yield
      restore_graphics_state
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.