I'm working with Fabric.js and I would like to draw arcs on canvas. The closest shape I can find is the Circle
shape. This, of course, only enables me to make a circle and nothing like an arc spanning 45° or 180°.
Is there a way to accomplish this with Fabric.js? If not, is there a way I can get the underlying context and then create the arc and allow fabric to manage it? It is important that I retain the selection and scaling capabilities that Fabric.js offers.
In latest version of FabricJS for circle were added startAngle
and endAngle
properties.
https://github.com/kangax/fabric.js/pull/1675
var canvas = new fabric.Canvas('c');
var circle = new fabric.Circle({
radius: 20,
left: 100,
top: 100,
angle: 45,
startAngle: 0,
endAngle: Math.PI,
stroke: '#000',
strokeWidth: 3,
fill: ''
});
Example: http://jsfiddle.net/mmeqec89/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With