e3b36616eaffd882c67c748091df106ce6a817ff7cd600bd5a9e933986b76d56186da8c883700d9d65a6ad75c824c45c7a34fe75084591b421b64177ba0026 773 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * 圆形
  3. */
  4. import Path, { PathProps } from '../Path';
  5. export class CircleShape {
  6. cx = 0
  7. cy = 0
  8. r = 0
  9. }
  10. export interface CircleProps extends PathProps {
  11. shape?: Partial<CircleShape>
  12. }
  13. class Circle extends Path<CircleProps> {
  14. shape: CircleShape
  15. constructor(opts?: CircleProps) {
  16. super(opts);
  17. }
  18. getDefaultShape() {
  19. return new CircleShape();
  20. }
  21. buildPath(ctx: CanvasRenderingContext2D, shape: CircleShape) {
  22. // Use moveTo to start a new sub path.
  23. // Or it will be connected to other subpaths when in CompoundPath
  24. ctx.moveTo(shape.cx + shape.r, shape.cy);
  25. ctx.arc(shape.cx, shape.cy, shape.r, 0, Math.PI * 2);
  26. }
  27. };
  28. Circle.prototype.type = 'circle';
  29. export default Circle;