开发者

How to draw a circle sector on an html5 canvas?

开发者 https://www.devze.com 2023-03-10 10:57 出处:网络
I\'m trying to make a sort of pie-chart shape on a canvas element, however I can\'t seem to find any function that does this by itself. I only seem to be able to draw full circles and segments. Is the

I'm trying to make a sort of pie-chart shape on a canvas element, however I can't seem to find any function that does this by itself. I only seem to be able to draw full circles and segments. Is there an easy开发者_如何学编程 way to do this?

(See also: Wikipedia on circle terminology)


The following should work:

context.moveTo(cx,cy);
context.arc(cx,cy,radius,startangle,endangle);
context.lineTo(cx,cy);
context.stroke(); // or context.fill()

with cx, cy being the center of the arc.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号