English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
createRadialGradient() ist eine Canvas 2Das D API bestimmt anhand der Parameter die Koordinaten zweier Kreise und zeichnet eine radioaktive Farbverlaufs-methode. Diese Methode gibt CanvasGradient zurück.
Zeichnen Sie ein Rechteck und füllen Sie es mit einem radialen/Kreisförmige Farbverlaufs-füllung:
!DOCTYPE html> <html> <head> <title>Verwendung der Methode createRadialGradient() für HTML canvas (Grundtutorials.net oldtoolbag.com)</title> </head> <body> <canvas id="myCanvas" width="300" height="150" style="border:1px fest #d3d3d3> Ihr Browser unterstützt keine HTML5 canvas-Tags. </canvas> <script> var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); var grd=ctx.createRadialGradient(75,50,5,90,60,100); grd.addColorStop(0,"rot"); grd.addColorStop(1,"weiß"); ctx.fillStyle=grd; ctx.fillRect(10,10,150,100); </script> </body> </html>Testen Sie es heraus ‹/›
IEFirefoxOperaChromeSafari
Internet Explorer 9Firefox, Opera, Chrome und Safari unterstützen createRadialGradient() method.
Note:Internet Explorer 8 and earlier versions do not support the <canvas> element.
The createRadialGradient() method creates a radial/Circular Gradient Object.
Gradients can be used to fill rectangles, circles, lines, text, and more
Tip:Please use this object asstrokeStyle or fillStyle the value of the property.
Tip:Please use addColorStop() The method specifies different colors and where to position the colors in the gradient object.
JavaScript Syntax: | context.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 | 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 | Radius of the ending circle |