Module: Prawn::Graphics::Gradient

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

Instance Method Summary collapse

Instance Method Details

#fill_gradient(point, width, height, color1, color2, options = {}) ⇒ Object

Sets the fill gradient from color1 to color2.

It accepts CMYK and RGB colors, like #fill_color. Both colors must be of the same type.

point, width and height define a bounding box in which the gradient will be rendered. For example, if you want to have page full of text with gradually changing color:

pdf.fill_gradient [0, pdf.bounds.height], pdf.bounds.width,
  pdf.bounds.height, 'FF0000', '0000FF'
pdf.text 'lots of text'*1000

:stroke_bounds - draw gradient bounds



26
27
28
# File 'lib/prawn/graphics/gradient.rb', line 26

def fill_gradient(point, width, height, color1, color2, options = {})
  set_gradient(:fill, point, width, height, color1, color2, options)
end

#stroke_gradient(point, width, height, color1, color2, options = {}) ⇒ Object

Sets the stroke gradient from color1 to color2.

See #fill_gradient for details.



33
34
35
# File 'lib/prawn/graphics/gradient.rb', line 33

def stroke_gradient(point, width, height, color1, color2, options = {})
  set_gradient(:stroke, point, width, height, color1, color2, options)
end