HTML कैनवास createRadialGradient () विधि
उदाहरण
एक आयत बनाएं और एक रेडियल/गोलाकार ढाल से भरें:
जावास्क्रिप्ट:
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var grd = ctx.createRadialGradient(75, 50, 5, 90, 60, 100);
grd.addColorStop(0, "red");
grd.addColorStop(1, "white");
// Fill with gradient
ctx.fillStyle = grd;
ctx.fillRect(10, 10, 150, 100);
ब्राउज़र समर्थन
तालिका में संख्याएं पहले ब्राउज़र संस्करण को निर्दिष्ट करती हैं जो पूरी तरह से विधि का समर्थन करता है।
Method | |||||
---|---|---|---|---|---|
createRadialGradient() | Yes | 9.0 | Yes | Yes | Yes |
परिभाषा और उपयोग
createRadialGradient() विधि एक रेडियल/सर्कुलर ग्रेडिएंट ऑब्जेक्ट बनाता है।
ग्रेडिएंट का उपयोग आयतों, वृत्तों, रेखाओं, पाठ आदि को भरने के लिए किया जा सकता है।
युक्ति: इस ऑब्जेक्ट का उपयोग स्ट्रोक शैली या भरण शैली गुणों के मान के रूप में करें ।
युक्ति: विभिन्न रंगों को निर्दिष्ट करने के लिए addColorStop() विधि का उपयोग करें , और ग्रेडिएंट ऑब्जेक्ट में रंगों को कहां रखें।
जावास्क्रिप्ट सिंटैक्स: | संदर्भ .createRadialGradient( x0,y0,r0,x1,y1,r1 ); |
---|
पैरामीटर मान
Parameter | Description |
---|---|
x0 | The x-coordinate of the starting circle of the gradient |
y0 | The y-coordinate of the starting circle of the gradient |
r0 | The radius of the starting circle |
x1 | The x-coordinate of the ending circle of the gradient |
y1 | The y-coordinate of the ending circle of the gradient |
r1 | The radius of the ending circle |
❮ HTML कैनवास संदर्भ