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() 메서드는 방사형/원형 그래디언트 객체를 만듭니다.
그라디언트는 사각형, 원, 선, 텍스트 등을 채우는 데 사용할 수 있습니다.
팁: 이 객체를 strokeStyle 또는 fillStyle 속성에 대한 값으로 사용하십시오.
팁: 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 캔버스 참조