根据javascriptcanvas中的角度绘制等腰三角形
Draw isocele triangle according to angle in javascript canvas
我想知道如何在canvas中画一个等腰三角形,如果我知道第一个角,以及两个等边的长度。
Shema (known lengths are in red)
第二个问题,是否可以像这样弯曲顶部:
Shema
var canvas = document.getElementById("canvas");
canvas.width = 500;
canvas.height = 500;
var ctx = canvas.getContext("2d");
ctx.closePath();
ctx.save();
function drawPie(ctx,centerX, centerY, radius, startAngle, endAngle ){
ctx.beginPath();
ctx.moveTo(centerX,centerY);
ctx.arc(centerX, centerY, radius, startAngle, endAngle);
ctx.closePath();
ctx.stroke();
}
drawPie(ctx, 200,200,200, -0.65*Math.PI, -0.60* Math.PI + Math.PI/4);
<canvas id="canvas"></canvas>
我想知道如何在canvas中画一个等腰三角形,如果我知道第一个角,以及两个等边的长度。
Shema (known lengths are in red)
第二个问题,是否可以像这样弯曲顶部:
Shema
var canvas = document.getElementById("canvas");
canvas.width = 500;
canvas.height = 500;
var ctx = canvas.getContext("2d");
ctx.closePath();
ctx.save();
function drawPie(ctx,centerX, centerY, radius, startAngle, endAngle ){
ctx.beginPath();
ctx.moveTo(centerX,centerY);
ctx.arc(centerX, centerY, radius, startAngle, endAngle);
ctx.closePath();
ctx.stroke();
}
drawPie(ctx, 200,200,200, -0.65*Math.PI, -0.60* Math.PI + Math.PI/4);
<canvas id="canvas"></canvas>