$applyPaint method
(Internal usage) Applies the paint to the given canvas
for this
GShape. If this GShape is being used as a mask, the graphics will be
used to clip the canvas
.
The canvas
parameter is the ui.Canvas object to apply the paint to.
Implementation
@override
void $applyPaint(ui.Canvas canvas) {
if (isMask && _graphics != null) {
GMatrix matrix;
var paths = _graphics!.getPaths();
if (inStage && $maskee!.inStage) {
matrix = getTransformationMatrix($maskee);
} else {
matrix = transformationMatrix;
}
var clipPath = paths.transform(matrix.toNative().storage);
final inverted = maskInverted || $maskee!.maskInverted;
if (inverted) {
_initInversePath();
// var invPath = Graphics.stageRectPath;
// var rect = $maskee.bounds;
// invPath = invPath.shift(Offset(rect.x, rect.y));
if (SystemUtils.usingSkia) {
clipPath = ui.Path.combine(
ui.PathOperation.difference, _inverseHugePath!, clipPath);
canvas.clipPath(clipPath);
} else {
trace('Shape.maskInverted is unsupported in the current platform');
}
} else {
canvas.clipPath(clipPath);
}
} else {
_graphics?.isMask = isMask;
_graphics?.alpha = worldAlpha;
_graphics?.paint(canvas);
}
}