withPerspective method
Implementation
Offset withPerspective({required double perspective, required double size}) {
// correct with perspective, relative to size
// invert height for calculation heightFactor because top of the shape is depth adjustment point
double y = size - dy;
// height of the location in shape determines the amount of perspective correction of the point
double locationHeightFactor = y > 0 ? y / size : 0;
double correction = size * perspective * locationHeightFactor;
return Offset(dx + correction, dy);
}