Module: Prawn::Graphics::Patterns

Included in:
Prawn::Graphics
Defined in:
lib/prawn/graphics/patterns.rb

Overview

Implements axial & radial gradients.

Defined Under Namespace

Classes: Gradient, GradientStop

Stable API collapse

Instance Method Details

#fill_gradient(from, to, color1, color2, apply_margin_options: false) ⇒ void #fill_gradient(from, r1, to, r2, color1, color2, apply_margin_options: false) ⇒ void #fill_gradient(from: , to: , r1: nil, r2: nil, stops: , apply_margin_options: true) ⇒ void

Sets the fill gradient.

Overloads:

  • #fill_gradient(from, to, color1, color2, apply_margin_options: false) ⇒ void

    This method returns an undefined value.

    Set an axial (linear) fill gradient.

  • #fill_gradient(from, r1, to, r2, color1, color2, apply_margin_options: false) ⇒ void

    This method returns an undefined value.

    Set a radial fill gradient.

  • #fill_gradient(from: , to: , r1: nil, r2: nil, stops: , apply_margin_options: true) ⇒ void

    This method returns an undefined value.

    Set the fill gradient.

    Examples:

    Draw a horizontal axial gradient that starts at red on the left and ends at blue on the right

    fill_gradient from: [0, 0], to: [100, 0], stops: ['ff0000', '0000ff']
    

    Draw a horizontal radial gradient that starts at red, is green 80% through, and finishes blue

    fill_gradient from: [0, 0], r1: 0, to: [100, 0], r2: 180,
      stops: { 0 => 'ff0000', 0.8 => '00ff00', 1 => '0000ff' }
    


105
106
107
# File 'lib/prawn/graphics/patterns.rb', line 105

def fill_gradient(*args, **kwargs)
  set_gradient(:fill, *args, **kwargs)
end

#fill_gradient(from, to, color1, color2, apply_margin_options: false) ⇒ void #fill_gradient(from, r1, to, r2, color1, color2, apply_margin_options: false) ⇒ void #fill_gradient(from: , to: , r1: nil, r2: nil, stops: , apply_margin_options: true) ⇒ void

Sets the stroke gradient.

Overloads:

  • #fill_gradient(from, to, color1, color2, apply_margin_options: false) ⇒ void

    This method returns an undefined value.

    Set an axial (linear) stroke gradient.

  • #fill_gradient(from, r1, to, r2, color1, color2, apply_margin_options: false) ⇒ void

    This method returns an undefined value.

    Set a radial stroke gradient.

  • #fill_gradient(from: , to: , r1: nil, r2: nil, stops: , apply_margin_options: true) ⇒ void

    This method returns an undefined value.

    Set the stroke gradient.

    Examples:

    Draw a horizontal axial gradient that starts at red on the left and ends at blue on the right

    stroke_gradient from: [0, 0], to: [100, 0], stops: ['ff0000', '0000ff']
    

    Draw a horizontal radial gradient that starts at red, is green 80% through, and finishes blue

    stroke_gradient from: [0, 0], r1: 0, to: [100, 0], r2: 180,
      stops: { 0 => 'ff0000', 0.8 => '00ff00', 1 => '0000ff' }
    


194
195
196
# File 'lib/prawn/graphics/patterns.rb', line 194

def stroke_gradient(*args, **kwargs)
  set_gradient(:stroke, *args, **kwargs)
end