strokeStyle ගුණය

strokeStyle ගුණය යනු canvas මත ඇඳීමේදී රේඛාවේ වර්ණය සකසා දෙන්නකි. මෙම ගුණයේ අගය ලෙස ඕනෑම CSS වර්ණ ඒකක භාවිතා කළ හැකිය.

වාක්‍ය රචනය

javascriptcontext.strokeStyle = color;

උදාහරණය

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.strokeStyle = 'red';
ctx.stroke();

Результат:

මේවාද බලන්න

  • fillStyle ක්‍රමය,
    රූපයේ පසුබිම් වර්ණය සකසයි