overlayMatrix function
Implementation
Matrix4 overlayMatrix({
required Offset origin,
required Size size,
required Alignment alignment,
required bool rotate,
double mapRotationRad = 0.0,
EdgeInsets margin = EdgeInsets.zero,
Offset pixelOffset = Offset.zero,
}) {
final f = _computeFrame(
origin: origin,
size: size,
alignment: alignment,
mapRotationRad: mapRotationRad,
rotate: rotate,
margin: margin,
);
final m = Matrix4.identity();
if (f.counter) {
final c = math.cos(-mapRotationRad);
final s = math.sin(-mapRotationRad);
final dx = f.tl.dx + pixelOffset.dx;
final dy = f.tl.dy + pixelOffset.dy;
final ax = f.ax;
final ay = f.ay;
// Col 0
m[0] = c;
m[1] = s;
// Col 1
m[4] = -s;
m[5] = c;
// Col 3 (Translation)
m[12] = ax * (1 - c) + ay * s + dx;
m[13] = ay * (1 - c) - ax * s + dy;
} else {
m.translateByDouble(
f.tl.dx + pixelOffset.dx,
f.tl.dy + pixelOffset.dy,
0.0,
1.0,
);
}
return m;
}