RectangleF2D.ts 897 B

123456789101112131415161718192021222324252627282930313233343536
  1. import {SizeF2D} from "./SizeF2D";
  2. import {PointF2D} from "./PointF2D";
  3. /**
  4. * Represent a rectangle on a plane
  5. */
  6. export class RectangleF2D {
  7. public x: number = 0;
  8. public y: number = 0;
  9. public width: number = 0;
  10. public height: number = 0;
  11. /**
  12. *
  13. * @param x
  14. * @param y
  15. * @param width
  16. * @param height
  17. */
  18. constructor(x: number, y: number, width: number, height: number) {
  19. this.x = x;
  20. this.y = y;
  21. this.width = width;
  22. this.height = height;
  23. }
  24. public static createFromLocationAndSize(location: PointF2D, size: SizeF2D): RectangleF2D {
  25. return new RectangleF2D(location.x, location.y, size.width, size.height);
  26. }
  27. public get Location(): PointF2D {
  28. return new PointF2D(this.x, this.y);
  29. }
  30. public get Size(): SizeF2D {
  31. return new SizeF2D(this.width, this.height);
  32. }
  33. }