strokeStyle गुण

strokeStyle गुण कैनवास पर ड्राइंग करते समय लाइन का रंग निर्धारित करता है। गुण का मान कोई भी 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 मेथड,
    जो आकृति की बैकग्राउंड रंग सेट करता है