Veturia textBaseline
Veturia textBaseline vendos rreshtimin vertikal
të tekstit, të vizatuar duke përdorur
metodën fillText
ose metodën strokeText.
Pranon një nga vlerat e mundshme: top,
hanging, middle, alphabetic (si parazgjedhje),
ideographic, bottom (për të kuptuar vlerat
shiko www.w3schools.com/tags/canvas_textbaseline.asp).
Sintaksa
konteksti.textBaseline = vlera;
Shembull
Le t'i caktojmë tekstit rreshtimin vertikal sipas vijës së sipërme:
<canvas id="canvas" width="200" height="200" style="background: #f4f4f4;"></canvas>
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
ctx.strokeStyle = 'red';
ctx.moveTo(0, 100);
ctx.lineTo(400, 100);
ctx.stroke();
ctx.font="14px Arial";
ctx.textBaseline = 'top';
ctx.fillText('text', 80, 100);
:
Shembull
Tani le t'i caktojmë tekstit rreshtimin vertikal sipas vijës së poshtme:
<canvas id="canvas" width="200" height="200" style="background: #f4f4f4;"></canvas>
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
ctx.strokeStyle = 'red';
ctx.moveTo(0, 100);
ctx.lineTo(400, 100);
ctx.stroke();
ctx.font="14px Arial";
ctx.textBaseline="bottom";
ctx.fillText('text', 80, 100);
: