0

I would like to know how can I draw an isocele triangle in canvas, if I know the first angle, and the lengths of the two equal side.

Shema (known lengths are in red)

And second question, is it possible to curve the top side like that :

Shema

  • you'd use canvas methods to draw and yes, you can do an arc like that - what have you done so far? – Bravo Apr 24 '22 at 07:16

1 Answers1

0

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>
debugger
  • 1,442
  • 1
  • 9
  • 14
  • While the code was what the questioner wanted, it would be more helpful to future readers, more generalisable, if you could explain what you had done. – A Haworth Apr 24 '22 at 09:49