Method: HexaPDF::Content::Canvas#translate
- Defined in:
- lib/hexapdf/content/canvas.rb
#translate(x, y, &block) ⇒ Object
:call-seq:
canvas.translate(x, y) => canvas
canvas.translate(x, y) { block } => canvas
Translates the coordinate system coordinate system origin to the given x and y coordinates and returns self.
If invoked with a block, the translation of the coordinate system is only active during the block by saving and restoring the graphics state.
Examples:
#>pdf-center
canvas.stroke_color("hp-gray-light").
rectangle(0, 0, 40, 20).stroke # Rectangle from (0, 0) to (40, 20)
canvas.translate(50, 50) do # Origin is now at (50, 50)
canvas.stroke_color("hp-blue").
rectangle(0, 0, 40, 20).stroke # Actually (50, 50) to (90, 70)
end
See: #transform
539 540 541 |
# File 'lib/hexapdf/content/canvas.rb', line 539 def translate(x, y, &block) transform(1, 0, 0, 1, x, y, &block) end |