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 820B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. export default class Circle extends CodeShape<CircleShape> {
  6. constructor(props = {} as Partial<CircleShape>) {
  7. props.point = vectorToPoint(props.point)
  8. super({
  9. id: uuid(),
  10. type: ShapeType.Circle,
  11. isGenerated: true,
  12. name: "Circle",
  13. parentId: "page0",
  14. childIndex: 0,
  15. point: [0, 0],
  16. rotation: 0,
  17. radius: 20,
  18. style: {
  19. fill: "#777",
  20. stroke: "#000",
  21. strokeWidth: 1,
  22. },
  23. ...props,
  24. })
  25. }
  26. export() {
  27. const shape = { ...this.shape }
  28. shape.point = vectorToPoint(shape.point)
  29. return shape
  30. }
  31. get radius() {
  32. return this.shape.radius
  33. }
  34. }