fillStyle বৈশিষ্ট্য

fillStyle বৈশিষ্ট্য ক্যানভাসে আঁকার সময় আকৃতি পূরণ করার রঙ নির্ধারণ করে। বৈশিষ্ট্যের মান হল যেকোনো CSS রঙের একক।

সিনট্যাক্স

javascriptপ্রসঙ্গ.fillStyle = রঙ;

উদাহরণ

আসুন rect ব্যবহার করে একটি বর্গ আঁকুন এবং এটি লাল রঙে পূরণ করুন:

html<canvas id="canvas" width="200" height="200" style="background: #f4f4f4;"></canvas>
javascriptlet canvas = document.querySelector('#canvas');
let ctx = canvas.getContext('2d');

ctx.rect(50, 50, 100, 100);
ctx.fillStyle = 'red';
ctx.fill();

Результат:

আরও দেখুন

  • strokeStyle পদ্ধতি,
    যা লাইনের রঙ সেট করে