Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
121
rated 0 times [  122] [ 1]  / answers: 1 / hits: 6444  / 10 Years ago, mon, september 22, 2014, 12:00:00

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.


More From » canvas

 Answers
9

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/


[#42359] Sunday, September 21, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
agustindejonm

Total Points: 738
Total Questions: 84
Total Answers: 84

Location: Northern Ireland
Member since Mon, Nov 14, 2022
2 Years ago
agustindejonm questions
Fri, Jun 25, 21, 00:00, 3 Years ago
Fri, Sep 18, 20, 00:00, 4 Years ago
Sat, May 16, 20, 00:00, 4 Years ago
;