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.

circle.ts 908B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import CodeShape from './index'
  2. import { v4 as uuid } from 'uuid'
  3. import { CircleShape, ShapeType } from 'types'
  4. import { vectorToPoint } from 'utils/utils'
  5. import { defaultStyle } from 'lib/shape-styles'
  6. export default class Circle extends CodeShape<CircleShape> {
  7. constructor(props = {} as Partial<CircleShape>) {
  8. props.point = vectorToPoint(props.point)
  9. super({
  10. id: uuid(),
  11. seed: Math.random(),
  12. type: ShapeType.Circle,
  13. isGenerated: true,
  14. name: 'Circle',
  15. parentId: 'page0',
  16. childIndex: 0,
  17. point: [0, 0],
  18. rotation: 0,
  19. radius: 20,
  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 radius() {
  33. return this.shape.radius
  34. }
  35. }