Draw numbers on the marker after highlighting them

This commit is contained in:
2026-01-04 13:08:54 -06:00
parent cf6322b511
commit f4048b1aec

View File

@@ -878,11 +878,24 @@ class GuitarDiagramsWebComponent extends HTMLElement {
timeGap += 0.5; timeGap += 0.5;
// Draw black after a timeout. This timeout is incremented by 0.5 from the 'draw yellow' one. // Draw black after a timeout. This timeout is incremented by 0.5 from the 'draw yellow' one.
// Also draw the numbers for the marker if they exist
setTimeout(() => { setTimeout(() => {
canvas.beginPath(); canvas.beginPath();
canvas.fillStyle = "black"; canvas.fillStyle = "black";
this.#drawMarkerCircle(marker.relativePosX, marker.relativePosY); this.#drawMarkerCircle(marker.relativePosX, marker.relativePosY);
canvas.closePath(); canvas.closePath();
canvas.beginPath();
canvas.fillStyle = marker.colorFont;
canvas.textAlign = "center";
canvas.textBaseline = "middle";
canvas.font = this.#scale(this.#config.markerFontSize) + "px Arial";
canvas.fillText(
marker.text,
marker.relativePosX,
marker.relativePosY + this.#scale(this.#config.markerStrokeWidth),
);
canvas.fill();
canvas.closePath();
}, timeGap * 1000); }, timeGap * 1000);
}); });
this.#outputSpeaker.triggerRelease(allNoteFrequencies, now + timeGap + 0.5); this.#outputSpeaker.triggerRelease(allNoteFrequencies, now + timeGap + 0.5);
@@ -908,7 +921,7 @@ class GuitarDiagramsWebComponent extends HTMLElement {
this.#outputSpeaker.triggerRelease(allNoteFrequencies, now + timeGap + 2); this.#outputSpeaker.triggerRelease(allNoteFrequencies, now + timeGap + 2);
// Draw everything black // Draw everything black and add numbers for the marker if they exist
this.#markers.forEach((marker) => { this.#markers.forEach((marker) => {
setTimeout( setTimeout(
() => { () => {
@@ -916,6 +929,18 @@ class GuitarDiagramsWebComponent extends HTMLElement {
canvas.fillStyle = "black"; canvas.fillStyle = "black";
this.#drawMarkerCircle(marker.relativePosX, marker.relativePosY); this.#drawMarkerCircle(marker.relativePosX, marker.relativePosY);
canvas.closePath(); canvas.closePath();
canvas.beginPath();
canvas.fillStyle = marker.colorFont;
canvas.textAlign = "center";
canvas.textBaseline = "middle";
canvas.font = this.#scale(this.#config.markerFontSize) + "px Arial";
canvas.fillText(
marker.text,
marker.relativePosX,
marker.relativePosY + this.#scale(this.#config.markerStrokeWidth),
);
canvas.fill();
canvas.closePath();
}, },
(timeGap + 1) * 1000, (timeGap + 1) * 1000,
); );