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 865B

12345678910111213141516171819202122232425262728293031323334353637
  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. isAspectRatioLocked: false,
  21. isLocked: false,
  22. isHidden: false,
  23. style: {
  24. fill: '#c6cacb',
  25. stroke: '#000',
  26. strokeWidth: 1,
  27. },
  28. ...props,
  29. })
  30. }
  31. get size() {
  32. return this.shape.size
  33. }
  34. }