選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

rectangle.ts 843B

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. 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. type: ShapeType.Rectangle,
  13. isGenerated: true,
  14. name: 'Rectangle',
  15. parentId: 'page0',
  16. childIndex: 0,
  17. point: [0, 0],
  18. size: [100, 100],
  19. rotation: 0,
  20. radius: 2,
  21. isAspectRatioLocked: false,
  22. isLocked: false,
  23. isHidden: false,
  24. style: defaultStyle,
  25. ...props,
  26. })
  27. }
  28. get size() {
  29. return this.shape.size
  30. }
  31. }