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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import CodeShape from './index'
  2. import { uniqueId } from 'utils'
  3. import { EllipseShape, ShapeProps, ShapeType } from 'types'
  4. import { defaultStyle } from 'state/shape-styles'
  5. /* ----------------- Start Copy Here ---------------- */
  6. export default class Ellipse extends CodeShape<EllipseShape> {
  7. constructor(props = {} as ShapeProps<EllipseShape>) {
  8. super({
  9. id: uniqueId(),
  10. parentId: (window as any).currentPageId,
  11. type: ShapeType.Ellipse,
  12. isGenerated: true,
  13. name: 'Ellipse',
  14. childIndex: 0,
  15. point: [0, 0],
  16. radiusX: 50,
  17. radiusY: 50,
  18. rotation: 0,
  19. isAspectRatioLocked: false,
  20. isLocked: false,
  21. isHidden: false,
  22. ...props,
  23. style: { ...defaultStyle, ...props.style },
  24. })
  25. }
  26. /**
  27. * The ellipse's x radius.
  28. *
  29. * ```ts
  30. * const shapeRadiusX = shape.radiusX
  31. *
  32. * shape.radiusX = 100
  33. * ```
  34. */
  35. get radiusX(): number {
  36. return this.shape.radiusX
  37. }
  38. set radiusX(radiusX: number) {
  39. this.utils.setProperty(this.shape, 'radiusX', radiusX)
  40. }
  41. /**
  42. * The ellipse's y radius.
  43. *
  44. * ```ts
  45. * const shapeRadiusY = shape.radiusY
  46. *
  47. * shape.radiusY = 100
  48. * ```
  49. */
  50. get radiusY(): number {
  51. return this.shape.radiusY
  52. }
  53. set radiusY(radiusY: number) {
  54. this.utils.setProperty(this.shape, 'radiusY', radiusY)
  55. }
  56. }