zoomedLayer method
Handles zooming of a layer.
This method calculates the zooming of a layer based on the specified parameters. It checks if the layer should be zoomed and performs the necessary transformations.
Returns true
if the layer was zoomed, otherwise false
.
Implementation
bool zoomedLayer({
required Layer layer,
required double scale,
required double scaleX,
required double oldFullH,
required double oldFullW,
required double pixelRatio,
required Rect cropRect,
required bool isHalfPi,
}) {
var paddingTop = cropRect.top / pixelRatio;
var paddingLeft = cropRect.left / pixelRatio;
var paddingRight = oldFullW - cropRect.right;
var paddingBottom = oldFullH - cropRect.bottom;
// important to check with < 1 and >-1 cuz crop-editor has rounding bugs
if (paddingTop > 0.1 ||
paddingTop < -0.1 ||
paddingLeft > 0.1 ||
paddingLeft < -0.1 ||
paddingRight > 0.1 ||
paddingRight < -0.1 ||
paddingBottom > 0.1 ||
paddingBottom < -0.1) {
var initialIconX = (layer.offset.dx - paddingLeft) * scaleX;
var initialIconY = (layer.offset.dy - paddingTop) * scaleX;
layer.offset = Offset(
initialIconX,
initialIconY,
);
layer.scale *= scale;
return true;
}
return false;
}