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विधि,
जो रेखा का रंग निर्धारित करती है