您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

rectangle.ts 765B

123456789101112131415161718192021222324252627282930313233
  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. style: {
  20. fill: "#777",
  21. stroke: "#000",
  22. strokeWidth: 1,
  23. },
  24. ...props,
  25. })
  26. }
  27. get size() {
  28. return this.shape.size
  29. }
  30. }