Konva JS why scenefunc context.circle is not working?

244 Views Asked by At

I am trying to create custom share a circle and BIN inside that circle to use as button. but context.circle is not working in documention they mentioned, rect, circle, text.. we can use with custom shape.

Please letme know what is the issue, is it bug or something i am missing.

var rect = new Konva.Shape({
        x: 10,
        y: 20,
        fill: '#00D2FF',
        radius: 10,
        sceneFunc: function (context, shape) {
          context.beginPath();
          context.circle(0, 0, 5);
          context.fillStrokeShape(shape);
        },
      });
1

There are 1 best solutions below

1
On

context argument is a wrapper around 2D native canvas context https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D.

You should use its methods to make drawings. In your case you may need context.arc: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/arc