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

rectangle.ts 870B

1234567891011121314151617181920212223242526272829303132333435
  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. import { defaultStyle } from 'lib/shape-styles'
  6. export default class Rectangle extends CodeShape<RectangleShape> {
  7. constructor(props = {} as Partial<RectangleShape>) {
  8. props.point = vectorToPoint(props.point)
  9. props.size = vectorToPoint(props.size)
  10. super({
  11. id: uuid(),
  12. seed: Math.random(),
  13. type: ShapeType.Rectangle,
  14. isGenerated: true,
  15. name: 'Rectangle',
  16. parentId: 'page0',
  17. childIndex: 0,
  18. point: [0, 0],
  19. size: [100, 100],
  20. rotation: 0,
  21. radius: 2,
  22. isAspectRatioLocked: false,
  23. isLocked: false,
  24. isHidden: false,
  25. style: defaultStyle,
  26. ...props,
  27. })
  28. }
  29. get size() {
  30. return this.shape.size
  31. }
  32. }