Module | Prawn::Graphics::Transformation |
In: |
lib/prawn/graphics/transformation.rb
|
Rotate the user space. If a block is not provided, then you must save and restore the graphics state yourself.
:origin: | [number, number]. The point around which to rotate. A block must be provided if using the :origin |
raises Prawn::Errors::BlockRequired if an :origin option is provided, but no block is given
Example without a block:
save_graphics_state rotate 30 text "rotated text" restore_graphics_state
Example with a block: rotating a rectangle around its upper-left corner
x = 300 y = 300 width = 150 height = 200 angle = 30 pdf.rotate(angle, :origin => [x, y]) do pdf.stroke_rectangle([x, y], width, height) end
Scale the user space. If a block is not provided, then you must save and restore the graphics state yourself.
:origin: | [number, number]. The point from which to scale. A block must be provided if using the :origin |
raises Prawn::Errors::BlockRequired if an :origin option is provided, but no block is given
Example without a block:
save_graphics_state scale 1.5 text "scaled text" restore_graphics_state
Example with a block: scale a rectangle from its upper-left corner
x = 300 y = 300 width = 150 height = 200 factor = 1.5 pdf.scale(angle, :origin => [x, y]) do pdf.stroke_rectangle([x, y], width, height) end
Transform the user space (see notes for rotate regarding graphics state) Generally, one would use the rotate, scale, translate, and skew convenience methods instead of calling transformation_matrix directly
Translate the user space. If a block is not provided, then you must save and restore the graphics state yourself.
Example without a block: move the text up and over 10
save_graphics_state translate(10, 10) text "scaled text" restore_graphics_state
Example with a block: draw a rectangle with its upper-left corner at
x + 10, y + 10 x = 300 y = 300 width = 150 height = 200 pdf.translate(10, 10) do pdf.stroke_rectangle([x, y], width, height) end