lineBitmapStyle method

Graphics lineBitmapStyle(
  1. GTexture texture, [
  2. GMatrix? matrix,
  3. bool repeat = true,
  4. bool smooth = false,
])

Sets the bitmap for drawing strokes. Use after lineStyle() to apply an image shader into the current Paint.

If _holeMode is true, the method will do nothing and return this Graphics object.

If matrix is not specified, the method uses _helperMatrix.

If repeat is true, the bitmap is tiled to fill the stroke.

If smooth is false, the method applies anti-aliasing to the stroke.

Returns this Graphics object after setting the bitmap for strokes.

Implementation

Graphics lineBitmapStyle(
  GTexture texture, [
  GMatrix? matrix,
  bool repeat = true,
  bool smooth = false,
]) {
  if (_holeMode) {
    return this;
  }
  assert(_currentDrawing!.fill?.style == PaintingStyle.stroke);
  final fill = _currentDrawing!.fill!;
  fill.isAntiAlias = smooth;
  var tileMode = !repeat ? TileMode.clamp : TileMode.repeated;
  matrix ??= _helperMatrix;
  fill.shader = ImageShader(
    texture.root!,
    tileMode,
    tileMode,
    matrix.toNative().storage,
  );
  return this;
}