icons that would otherwise be clipped are placed within the canvas bounds

This commit is contained in:
joe 2025-04-26 14:00:45 +01:00
parent 52fcdfa1ba
commit 169da90607
1 changed files with 4 additions and 1 deletions

View File

@ -79,6 +79,7 @@ export class Renderer {
const rect = this.timeIndicator.getBoundingClientRect();
const sheetLeft = this.sheetWindow.getBoundingClientRect().left;
const sheetRight = this.sheetWindow.getBoundingClientRect().right;
const xPosition = rect.left + window.scrollX - sheetLeft;
const canvasEntry = this.canvases[this.currStaveNumber - 1];
@ -91,6 +92,8 @@ export class Renderer {
const width = instrument.width * this.iconScale;
const height = instrument.height * this.iconScale;
if(xPosition + width > sheetRight) xPosition -= width;
ctx.drawImage(instrument.image, xPosition, y, width, height);
this.iconCache.push({