Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class ImagePaint

  1. Object
  2. ArtPaint
  3. ImagePaint

Fills with an image, stretched or tiled.

The image’s pixel grid is placed in paint space by getTransform; one image pixel is one unit before that transform.

Constructors

public ImagePaint(Raster image)Creates an image paint.

Methods

public ArtPaint copy()A deep copy.
public Raster getImage()The image.
public Matrix getTransform()The image transform.
public void setTransform(Matrix transform)Sets the image transform.
public boolean isTiled()True when the image repeats.
public void setTiled(boolean tiled)Sets whether the image repeats.
public boolean isObjectBoundingBox()True when the transform maps the unit square onto the bounding box first, so a transform of scale(1/w, 1/h) stretches the image over the shape.
public void setObjectBoundingBox(boolean objectBoundingBox)Sets whether the transform is relative to the bounding box.
public void fit(double x, double y, double w, double h)Stretches the image over a rectangle.
public int colorAt(double x, double y, double[] bbox)The color at a point of paint space.

Inherited methods

Constructor details

ImagePaint

public ImagePaint(Raster image)
Creates an image paint.

Parameters

image Raster
the pixels

Method details

copy

public ArtPaint copy()
A deep copy.

getImage

public Raster getImage()
The image.

getTransform

public Matrix getTransform()
The image transform.

setTransform

public void setTransform(Matrix transform)
Sets the image transform.

Parameters

transform Matrix
places the image in paint space

isTiled

public boolean isTiled()
True when the image repeats.

setTiled

public void setTiled(boolean tiled)
Sets whether the image repeats.

Parameters

tiled boolean
true to repeat

isObjectBoundingBox

public boolean isObjectBoundingBox()
True when the transform maps the unit square onto the bounding box first, so a transform of scale(1/w, 1/h) stretches the image over the shape.

setObjectBoundingBox

public void setObjectBoundingBox(boolean objectBoundingBox)
Sets whether the transform is relative to the bounding box.

Parameters

objectBoundingBox boolean
true to stretch over the shape’s bounds

fit

public void fit(double x, double y, double w, double h)
Stretches the image over a rectangle.

Parameters

x double
left
y double
top
w double
width
h double
height

colorAt

public int colorAt(double x, double y, double[] bbox)
The color at a point of paint space.

Parameters

x double
x in the space of the shape that is painted
y double
y in that space
bbox double[]
the shape’s bounding box as x, y, w, h, for paints relative to it