转:
Canvas 如何画一个四分之一圆
HTML:
Document
JS:
var c = document.getElementById('ctx')
var ctx = c.getContext('2d');
var x = 100;
var y = 50;
var RADIUS = 80;
ctx.beginPath();
ctx.arc(x, y, RADIUS, Math.PI / 2, Math.PI); //sAngle 90 ,eAngle 180
ctx.fillStyle = '#333';
ctx.lineTo(x, y);
ctx.fill();
ctx.restore();
ctx.stroke();
https://jsfiddle.net/jhyp83u4/
HTML:
Document
JS:
var c = document.getElementById('ctx')
var ctx = c.getContext('2d');
var x = 100;
var y = 50;
var RADIUS = 80;
ctx.beginPath();
ctx.arc(x, y, RADIUS, Math.PI / 2, Math.PI); //sAngle 90 ,eAngle 180
ctx.fillStyle = '#333';
ctx.lineTo(x, y);
ctx.fill();
ctx.restore();
ctx.stroke();
https://jsfiddle.net/jhyp83u4/
转: