Skip to content

Translate

Returns a new image with the original image translated (moved) the specified number of pixels. We can translate on either axis and in either direction. Additionally, a background colour can be specified.

Examples

Using this image as our input:

source image

 // translate 100 pixels right
image.translate(100, 0)

image

 // translate 100 pixels right with specified bg
image.translate(100, 0, Color.BLUE)

image

 // translate on both axis
image.translate(120, 80)

image

 // translate in negative directions with specified bg
image.translate(120, -80, Color.RED)

image