[英]fill ouline of arc in html5 canvas
I want to draw a shape like this using html5 canvas 我想使用html5画布绘制这样的形状
but I don't want to use curves. 但我不想使用曲线。 is there any way to draw it using arc function ?
有什么办法可以使用arc函数绘制它?
or at least how can I draw a curve exactly like when I have given center point and radius for an arc function. 或者至少如何像给定圆弧函数的中心点和半径时完全绘制一条曲线。
Thanks a million . 太感谢了 。
This should help, try this: 这应该会有所帮助,请尝试以下操作:
<canvas id="myCanvas" width="200" height="200"></canvas>
<script>
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
var x = canvas.width / 2;
var y = canvas.height / 2;
var radius = 75;
var startAngle = 0 * Math.PI;
var endAngle = 1 * Math.PI;
var counterClockwise = false;
context.beginPath();
context.arc(x, y, radius, startAngle, endAngle, counterClockwise);
context.lineTo(x - radius, 200);
context.lineTo(x + radius, 200);
context.closePath();
context.stroke();
context.fillStyle = 'red';
context.fill();
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.