*/
const getCenter = (canvas) => getDimensions(canvas).map((dim) => dim / 2);
+const getRectangleDimensionsUnbound = (canvas, xScale, yScale) => {
+ [width, height] = getDimensions(canvas);
+ return [width * xScale, height * yScale];
+}
+
+const getRectangleDimensions = (canvas) => getRectangleDimensionsUnbound(canvas, .5, .1);
+
/**
* Draw champion box and clear background.
*/
const ctx = canvas.getContext("2d");
const [width, height] = getDimensions(canvas);
const [mid_x, mid_y] = getCenter(canvas);
- const rect_width = width * .5;
- const rect_height = height * .1;
+ const [rect_width, rect_height] = getRectangleDimensions(canvas);
ctx.strokeRect(mid_x - rect_width / 2, mid_y - rect_height / 2, rect_width, rect_height);
ctx.clearRect(mid_x - rect_width / 2, mid_y - rect_height / 2, rect_width, rect_height);
}
const drawBracket = (canvas, artists) => {
drawWinner(canvas);
const [mid_x, mid_y] = getCenter(canvas);
+ const [rect_width, rect_height] = getRectangleDimensions(canvas);
const groups = 4;
const rounds = Math.log2(artists.length / groups);
for (let group = 1; group <= groups; group++) {