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.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import CodeShape from './index'
  2. import { uniqueId } from 'utils/utils'
  3. import { EllipseShape, ShapeType } from 'types'
  4. import { vectorToPoint } from 'utils/utils'
  5. import { defaultStyle } from 'lib/shape-styles'
  6. export default class Ellipse extends CodeShape<EllipseShape> {
  7. constructor(props = {} as Partial<EllipseShape>) {
  8. props.point = vectorToPoint(props.point)
  9. super({
  10. id: uniqueId(),
  11. seed: Math.random(),
  12. parentId: (window as any).currentPageId,
  13. type: ShapeType.Ellipse,
  14. isGenerated: true,
  15. name: 'Ellipse',
  16. childIndex: 0,
  17. point: [0, 0],
  18. radiusX: 20,
  19. radiusY: 20,
  20. rotation: 0,
  21. isAspectRatioLocked: false,
  22. isLocked: false,
  23. isHidden: false,
  24. ...props,
  25. style: { ...defaultStyle, ...props.style },
  26. })
  27. }
  28. export() {
  29. const shape = { ...this.shape }
  30. shape.point = vectorToPoint(shape.point)
  31. return shape
  32. }
  33. get radiusX() {
  34. return this.shape.radiusX
  35. }
  36. get radiusY() {
  37. return this.shape.radiusY
  38. }
  39. }