Class ImagePaint

java.lang.Object
com.codename1.art.ArtPaint
com.codename1.art.ImagePaint

public final class ImagePaint extends ArtPaint

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.

  • Constructor Details

    • ImagePaint

      public ImagePaint(Raster image)

      Creates an image paint.

      Parameters
      • image: the pixels
  • Method Details

    • copy

      public ArtPaint copy()
      Description copied from class: ArtPaint
      A deep copy.
      Specified by:
      copy in class ArtPaint
    • 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: 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: 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: 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: left
      • y: top
      • w: width
      • h: height
    • colorAt

      public int colorAt(double x, double y, double[] bbox)
      Description copied from class: ArtPaint

      The color at a point of paint space.

      Parameters
      • x: x in the space of the shape that is painted
      • y: y in that space
      • bbox: the shape's bounding box as x, y, w, h, for paints relative to it
      Specified by:
      colorAt in class ArtPaint