ImageShader constructor

ImageShader(
  1. Image image,
  2. TileMode tmx,
  3. TileMode tmy,
  4. Float64List matrix4, {
  5. FilterQuality? filterQuality,
})

Creates an image-tiling shader.

The first argument specifies the image to render. The decodeImageFromList function can be used to decode an image from bytes into the form expected here. (In production code, starting from instantiateImageCodec may be preferable.)

The second and third arguments specify the TileMode for the x direction and y direction respectively. TileMode.repeated can be used for tiling images.

The fourth argument gives the matrix to apply to the effect. The expression Matrix4.identity().storage creates a Float64List prepopulated with the identity matrix.

All the arguments are required and must not be null, except for filterQuality. If filterQuality is not specified at construction time it will be deduced from the environment where it is used, such as from Paint.filterQuality.

Implementation

@pragma('vm:entry-point')
ImageShader(Image image, TileMode tmx, TileMode tmy, Float64List matrix4, {
  FilterQuality? filterQuality,
}) :
  assert(!image.debugDisposed),
  super._() {
  if (matrix4.length != 16) {
    throw ArgumentError('"matrix4" must have 16 entries.');
  }
  _constructor();
  final String? error = _initWithImage(image._image, tmx.index, tmy.index, filterQuality?.index ?? -1, matrix4);
  if (error != null) {
    throw Exception(error);
  }
}