You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rectangle.ts 785B

12345678910111213141516171819202122232425262728293031323334
  1. import CodeShape from "./index"
  2. import { v4 as uuid } from "uuid"
  3. import { RectangleShape, ShapeType } from "types"
  4. import { vectorToPoint } from "utils/utils"
  5. export default class Rectangle extends CodeShape<RectangleShape> {
  6. constructor(props = {} as Partial<RectangleShape>) {
  7. props.point = vectorToPoint(props.point)
  8. props.size = vectorToPoint(props.size)
  9. super({
  10. id: uuid(),
  11. type: ShapeType.Rectangle,
  12. isGenerated: true,
  13. name: "Rectangle",
  14. parentId: "page0",
  15. childIndex: 0,
  16. point: [0, 0],
  17. size: [100, 100],
  18. rotation: 0,
  19. radius: 2,
  20. style: {
  21. fill: "#c6cacb",
  22. stroke: "#000",
  23. strokeWidth: 1,
  24. },
  25. ...props,
  26. })
  27. }
  28. get size() {
  29. return this.shape.size
  30. }
  31. }