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.

ellipse.ts 962B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import CodeShape from './index'
  2. import { v4 as uuid } from 'uuid'
  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: uuid(),
  11. type: ShapeType.Ellipse,
  12. isGenerated: true,
  13. name: 'Ellipse',
  14. parentId: 'page0',
  15. childIndex: 0,
  16. point: [0, 0],
  17. radiusX: 20,
  18. radiusY: 20,
  19. rotation: 0,
  20. isAspectRatioLocked: false,
  21. isLocked: false,
  22. isHidden: false,
  23. style: defaultStyle,
  24. ...props,
  25. })
  26. }
  27. export() {
  28. const shape = { ...this.shape }
  29. shape.point = vectorToPoint(shape.point)
  30. return shape
  31. }
  32. get radiusX() {
  33. return this.shape.radiusX
  34. }
  35. get radiusY() {
  36. return this.shape.radiusY
  37. }
  38. }