HTMLキャンバスcreateRadialGradient()メソッド

❮HTMLキャンバスリファレンス

長方形を描き、放射状/円形のグラデーションで塗りつぶします。

あなたのブラウザはHTML5canvastagをサポートしていません。

JavaScript:

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()メソッドは、放射状/円形のグラデーションオブジェクトを作成します。

グラデーションは、長方形、円、線、テキストなどを塗りつぶすために使用できます。

ヒント:このオブジェクトを strokeStyleまたはfillStyleプロパティの値として使用します。

ヒント:addColorStop()メソッドを使用して、さまざまな色を指定し、グラデーションオブジェクトのどこに色を配置するかを指定します。

JavaScript構文: 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 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キャンバスリファレンス