English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Referenzhandbuch

HTML-Tag-Liste

HTML canvas createRadialGradient() Methode

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.

HTML canvas Reference Manual

Online-Beispiel

Zeichnen Sie ein Rechteck und füllen Sie es mit einem radialen/Kreisförmige Farbverlaufs-füllung:

Ihr Browser unterstützt keine HTML5 canvas-Tag.
!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 ‹/›

Browserkompatibilität

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.

Definition and Usage

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 Value

ParameterDescription
x0The x-coordinate of the starting circle of the gradient
y0The y-coordinate of the starting circle of the gradient
r0Radius of the starting circle
x1The x-coordinate of the ending circle of the gradient
y1The y-coordinate of the ending circle of the gradient
r1Radius of the ending circle
HTML canvas Reference Manual