34 lines
800 B
JavaScript
34 lines
800 B
JavaScript
/*!
|
|
* Tectum
|
|
* Copyright © 2026 Machiel Heinen.
|
|
* Alle rechten voorbehouden. Gebruik uitsluitend met schriftelijke toestemming.
|
|
* Zie LICENTIE.md.
|
|
*/
|
|
|
|
const CANVAS_LABEL_COLOR = '#4da6ff';
|
|
|
|
function drawCanvasDim(ctx, x1, y1, x2, y2, text, textX, textY) {
|
|
ctx.save();
|
|
ctx.strokeStyle = CANVAS_LABEL_COLOR;
|
|
ctx.fillStyle = CANVAS_LABEL_COLOR;
|
|
ctx.lineWidth = 1;
|
|
ctx.setLineDash([]);
|
|
ctx.font = '10px sans-serif';
|
|
ctx.textAlign = 'center';
|
|
ctx.textBaseline = 'alphabetic';
|
|
|
|
ctx.beginPath();
|
|
ctx.moveTo(x1, y1);
|
|
ctx.lineTo(x2, y2);
|
|
ctx.stroke();
|
|
|
|
if (Math.abs(x1 - x2) < 0.5 && Math.abs(y1 - y2) >= 0.5) {
|
|
ctx.translate(textX, textY);
|
|
ctx.rotate(-Math.PI / 2);
|
|
ctx.fillText(text, 0, 0);
|
|
} else {
|
|
ctx.fillText(text, textX, textY);
|
|
}
|
|
ctx.restore();
|
|
}
|