Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function drawTriangle(sideOne, sideTwo, sideThree) {
- var canvas = document.getElementById('triangle-canvas');
- var ctx = canvas.getContext('2d');
- var cx = canvas.width / 2;
- var cy = canvas.height / 4;
- var sideOneHeight = sideOne * (Math.sqrt(3) / 2);
- var sideTwoHeight = sideTwo * (Math.sqrt(3) / 2);
- ctx.beginPath();
- ctx.moveTo(cx, cy);
- ctx.lineTo(cx + 50, cy + sideOneHeight);
- ctx.lineTo(cx - 50, cy + sideTwoHeight);
- ctx.lineTo(cx, cy);
- ctx.fill();
- ctx.closePath();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement