textBaseline বৈশিষ্ট্য
textBaseline বৈশিষ্ট্য
fillText পদ্ধতি
বা strokeText পদ্ধতি ব্যবহার করে আঁকা টেক্সটের উল্লম্ব
অ্যালাইনমেন্ট নির্দিষ্ট করে। সম্ভাব্য মানগুলির মধ্যে একটি গ্রহণ করে: top,
hanging, middle, alphabetic (ডিফল্ট),
ideographic, bottom (মানগুলি বোঝার জন্য
দেখুন www.w3schools.com/tags/canvas_textbaseline.asp)।
সিনট্যাক্স
context.textBaseline = মান;
উদাহরণ
আসুন টেক্সটকে উল্লম্বভাবে উপরের লাইনে অ্যালাইন করি:
<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);
:
উদাহরণ
এবং এখন আসুন টেক্সটকে উল্লম্বভাবে নীচের লাইনে অ্যালাইন করি:
<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);
: