javascript - How to create a custom circle with arc method? -


i want customize arc() function able make own circle, can't draw flattened cicrle.

enter image description here

how can this?

var c = document.getelementbyid("mycanvas");  var ctx = c.getcontext("2d");  ctx.beginpath();  ctx.arc(100, 75, 50, 0, 2 * math.pi);  ctx.stroke();
<canvas id="mycanvas" width="200" height="150" style="border:1px solid #d3d3d3;"></canvas>

arc piece of circle. use scale transform circle ellipse:

edit: use save , restore keep canvas state. keep line-width constant.

var c = document.getelementbyid("mycanvas");  var ctx = c.getcontext("2d");  ctx.linewidth=5;  ctx.save();  ctx.beginpath();  ctx.scale(2,1);  ctx.arc(50, 75, 40, 0, 2*math.pi);  ctx.restore();  ctx.stroke();
<canvas id="mycanvas" width="200" height="150" style="border:1px solid #d3d3d3;"></canvas>


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -