Sifa textBaseline
Sifa textBaseline inabainisha upanganishaji wima
wa maandishi, yaliyochorwa kwa kutumia
mtindo fillText
au mtindo strokeText.
Inakubali moja ya thamani zinazowezekana: top,
hanging, middle, alphabetic (kwa default),
ideographic, bottom (kwa ufahamu wa maadili
tazama www.w3schools.com/tags/canvas_textbaseline.asp).
Syntax
muktadha.textBaseline = thamani;
Mfano
Wacha tuweke upanganishaji wima wa maandishi kwenye mstari wa juu:
<canvas id="canvas" width="200" height="200" style="background: #f4f4f4;"></canvas>
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
ctx.strokeStyle = 'nyekundu';
ctx.moveTo(0, 100);
ctx.lineTo(400, 100);
ctx.stroke();
ctx.font="14px Arial";
ctx.textBaseline = 'juu';
ctx.fillText('maandishi', 80, 100);
:
Mfano
Sasa wacha tuweke upanganishaji wima wa maandishi kwenye mstari wa chini:
<canvas id="canvas" width="200" height="200" style="background: #f4f4f4;"></canvas>
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
ctx.strokeStyle = 'nyekundu';
ctx.moveTo(0, 100);
ctx.lineTo(400, 100);
ctx.stroke();
ctx.font="14px Arial";
ctx.textBaseline="chini";
ctx.fillText('maandishi', 80, 100);
: