paintOnPath method
void
paintOnPath(
- Canvas canvas,
- Size size,
- Path path, {
- PatternScaleBehavior patternScaleBehavior = PatternScaleBehavior.container,
- Rect? customRect,
If PatternScaleBehavior.customRect is specified, you must also provide a customRect
to scale the Pattern to.
Implementation
void paintOnPath(Canvas canvas, Size size, Path path,
{PatternScaleBehavior patternScaleBehavior =
PatternScaleBehavior.container,
Rect? customRect}) {
canvas.save();
canvas.clipPath(path);
switch (patternScaleBehavior) {
case PatternScaleBehavior.container:
final Rect boundsRect = path.getBounds();
final pathW = boundsRect.width,
pathH = boundsRect.height,
pathX = boundsRect.left,
pathY = boundsRect.top;
paintWithPattern(canvas, pathX, pathY, pathW, pathH);
break;
case PatternScaleBehavior.canvas:
paintOnCanvas(canvas, size);
break;
case PatternScaleBehavior.customRect:
(customRect != null)
? paintWithPattern(canvas, customRect.left, customRect.top,
customRect.width, customRect.height)
: paintOnCanvas(canvas, size);
break;
}
canvas.restore();
}