fillStyle ගුණය
fillStyle ගුණය මගින් canvas හි අඳින රූපයක් පිරවීමේ වර්ණය සකසයි.
මෙම ගුණයේ අගය වන්නේ ඕනෑම CSS
වර්ණ ඒකක වේ.
වාක්ය රීතිය
context.fillStyle = color;
උදාහරණය
අපි දැන් rect ක්රමය භාවිතා කර චතුරස්රයක් අඳිමු
සහ එය රතු වර්ණයෙන් පුරවමු:
<canvas id="canvas" width="200" height="200" style="background: #f4f4f4;"></canvas>
let canvas = document.querySelector('#canvas');
let ctx = canvas.getContext('2d');
ctx.rect(50, 50, 100, 100);
ctx.fillStyle = 'red';
ctx.fill();
:
මෙයද බලන්න
-
strokeStyleක්රමය,
යම් රේඛාවක වර්ණය සකසයි