Tela HTML método createRadialGradient()
Exemplo
Desenhe um retângulo e preencha com um gradiente radial/circular:
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);
Suporte ao navegador
Os números na tabela especificam a primeira versão do navegador que oferece suporte total ao método.
Method | |||||
---|---|---|---|---|---|
createRadialGradient() | Yes | 9.0 | Yes | Yes | Yes |
Definição e uso
O método createRadialGradient() cria um objeto gradiente radial/circular.
O gradiente pode ser usado para preencher retângulos, círculos, linhas, texto, etc.
Dica: Use este objeto como o valor para as propriedades strokeStyle ou fillStyle .
Dica: Use o método addColorStop() para especificar cores diferentes e onde posicionar as cores no objeto gradiente.
Sintaxe JavaScript: | context .createRadialGradient( x0,y0,r0,x1,y1,r1 ); |
---|
Valores de parâmetro
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 |
❮ Referência de tela HTML