canvas = {
const width = 300;
const height = width;
const ctx = DOM.context2d(width, height);
ctx.canvas.style.width = `${width}px`;
ctx.canvas.style.height = `${height}px`;
const triangleBase = width;
const triangleHeight = Math.round((triangleBase * Math.sqrt(3)) / 2);
const triangleHalf = triangleBase / 2;
const trianglesVertices = [
{
v0: [triangleHalf, 0],
v1: [0, triangleHeight],
v2: [triangleBase, triangleHeight]
},
{
v0: [0, triangleHeight],
v1: [triangleHalf, 0],
v2: [triangleBase, triangleHeight]
},
{
v0: [0, triangleHeight],
v1: [triangleBase, triangleHeight],
v2: [triangleHalf, 0]
}
];
const steps = 25;
const parabolaColor = "rgb(239 68 68 / 50%)";
trianglesVertices.forEach((vertex) =>
drawParabola(ctx, steps, parabolaColor, vertex)
);
return ctx.canvas;
}