generated from gxc-solutions/gxc-template-repo
Added Matrix2d class, update Transform class
This commit is contained in:
parent
e5f5f3a08e
commit
4dbba31ed5
7 changed files with 159 additions and 1 deletions
|
|
@ -1 +1,15 @@
|
|||
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);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue