generated from gxc-solutions/gxc-template-repo
All checks were successful
CI / build (push) Successful in 29s
Added Matrix2d class, update Transform class
15 lines
581 B
TypeScript
15 lines
581 B
TypeScript
import { Rectangle, Transform } from "../models";
|
|
|
|
export const degToRad = (deg: number) => (deg * Math.PI) / 180;
|
|
export const radToDeg = (radians: number) => radians * (180 / Math.PI);
|
|
|
|
export const getBounds = (rectangle: Rectangle, transform: Transform) => {
|
|
const { top, left, bottom, right } = rectangle;
|
|
|
|
const matrix2d = transform.toMatrix2D();
|
|
|
|
const topLeft = matrix2d.transformPoint({ x: left, y: top });
|
|
const bottomRight = matrix2d.transformPoint({ x: right, y: bottom });
|
|
|
|
return Rectangle.fromPoints(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y);
|
|
};
|