module Prawn::Graphics::Patterns
Implements axial & radial gradients.
Constants
- Gradient
-
@private
- GradientStop
-
Gradientcolor stop. @private
Public Instance Methods
Source
# File lib/prawn/graphics/patterns.rb, line 105 def fill_gradient(*args, **kwargs) set_gradient(:fill, *args, **kwargs) end
Sets the fill gradient.
@overload fill_gradient(from, to, color1, color2, apply_margin_options: false)
Set an axial (linear) fill gradient. @param from [Array(Number, Number)] Starting point of the gradient. @param to [Array(Number, Number)] ending point of the gradient. @param color1 [Color] starting color of the gradient. @param color2 [Color] ending color of the gradient. @param apply_transformations [Boolean] (false) If set `true`, will transform the gradient's co-ordinate space so it matches the current co-ordinate space of the document. This option will be the default from Prawn v3, and is default `true` if you use the all-keyword version of this method. The default for the positional arguments version (this one), `false`, will mean if you (for example) scale your document by 2 and put a gradient inside, you will have to manually multiply your co-ordinates by 2 so the gradient is correctly positioned. @return [void]
@overload fill_gradient(from, r1, to, r2, color1, color2, apply_margin_options: false)
Set a radial fill gradient. @param from [Array(Number, Number)] Starting point of the gradient. @param r1 [Number] Radius of the starting circle of a radial gradient. The circle is centered at `from`. @param to [Array(Number, Number)] Ending point of the gradient. @param r2 [Number] Radius of the ending circle of a radial gradient. The circle is centered at `to`. @param color1 [Color] Starting color. @param color2 [Color] Ending color. @param apply_transformations [Boolean] (false) If set `true`, will transform the gradient's co-ordinate space so it matches the current co-ordinate space of the document. This option will be the default from Prawn v3, and is default `true` if you use the all-keyword version of this method. The default for the positional arguments version (this one), `false`, will mean if you (for example) scale your document by 2 and put a gradient inside, you will have to manually multiply your co-ordinates by 2 so the gradient is correctly positioned. @return [void]
@overload fill_gradient(from:, to:, r1: nil, r2: nil, stops:, apply_margin_options: true)
Set the fill gradient.
@example 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']
@example 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' }
@param from [Array(Number, Number)]
Starting point of the gradient.
@param r1 [Number, nil]
Radius of the starting circle of a radial gradient. The circle is
centered at `from`. If omitted a linear gradient will be produced.
@param to [Array(Number, Number)]
Ending point of the gradient.
@param r2 [Number, nil]
Radius of the ending circle of a radial gradient. The circle is
centered at `to`.
@param stops [Array<Color>, Hash{Number => Color}]
Color stops. Each stop is either just a color, in which case the
stops will be evenly distributed across the gradient, or a hash
where the key is a position between 0 and 1 indicating what distance
through the gradient the color should change, and the value is
a color.
@param apply_transformations [Boolean] (true)
If set `true`, will transform the gradient's co-ordinate space so it
matches the current co-ordinate space of the document. This option
will be the default from Prawn v3, and is default `true` if you use
the all-keyword version of this method (this one). The default for
the old arguments format, `false`, will mean if you (for example)
scale your document by 2 and put a gradient inside, you will have to
manually multiply your co-ordinates by 2 so the gradient is
correctly positioned.
@return [void]
Source
# File lib/prawn/graphics/patterns.rb, line 194 def stroke_gradient(*args, **kwargs) set_gradient(:stroke, *args, **kwargs) end
Sets the stroke gradient.
@overload fill_gradient(from, to, color1, color2, apply_margin_options: false)
Set an axial (linear) stroke gradient. @param from [Array(Number, Number)] Starting point of the gradient. @param to [Array(Number, Number)] ending point of the gradient. @param color1 [Color] starting color of the gradient. @param color2 [Color] ending color of the gradient. @param apply_transformations [Boolean] (false) If set `true`, will transform the gradient's co-ordinate space so it matches the current co-ordinate space of the document. This option will be the default from Prawn v3, and is default `true` if you use the all-keyword version of this method. The default for the positional arguments version (this one), `false`, will mean if you (for example) scale your document by 2 and put a gradient inside, you will have to manually multiply your co-ordinates by 2 so the gradient is correctly positioned. @return [void]
@overload fill_gradient(from, r1, to, r2, color1, color2, apply_margin_options: false)
Set a radial stroke gradient. @param from [Array(Number, Number)] Starting point of the gradient. @param r1 [Number] Radius of the starting circle of a radial gradient. The circle is centered at `from`. @param to [Array(Number, Number)] Ending point of the gradient. @param r2 [Number] Radius of the ending circle of a radial gradient. The circle is centered at `to`. @param color1 [Color] Starting color. @param color2 [Color] Ending color. @param apply_transformations [Boolean] (false) If set `true`, will transform the gradient's co-ordinate space so it matches the current co-ordinate space of the document. This option will be the default from Prawn v3, and is default `true` if you use the all-keyword version of this method. The default for the positional arguments version (this one), `false`, will mean if you (for example) scale your document by 2 and put a gradient inside, you will have to manually multiply your co-ordinates by 2 so the gradient is correctly positioned. @return [void]
@overload fill_gradient(from:, to:, r1: nil, r2: nil, stops:, apply_margin_options: true)
Set the stroke gradient.
@example 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']
@example 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' }
@param from [Array(Number, Number)]
Starting point of the gradient.
@param r1 [Number, nil]
Radius of the starting circle of a radial gradient. The circle is
centered at `from`. If omitted a linear gradient will be produced.
@param to [Array(Number, Number)]
Ending point of the gradient.
@param r2 [Number, nil]
Radius of the ending circle of a radial gradient. The circle is
centered at `to`.
@param stops [Array<Color>, Hash{Number => Color}]
Color stops. Each stop is either just a color, in which case the
stops will be evenly distributed across the gradient, or a hash
where the key is a position between 0 and 1 indicating what distance
through the gradient the color should change, and the value is
a color.
@param apply_transformations [Boolean] (true)
If set `true`, will transform the gradient's co-ordinate space so it
matches the current co-ordinate space of the document. This option
will be the default from Prawn v3, and is default `true` if you use
the all-keyword version of this method (this one). The default for
the old arguments format, `false`, will mean if you (for example)
scale your document by 2 and put a gradient inside, you will have to
manually multiply your co-ordinates by 2 so the gradient is
correctly positioned.
@return [void]