본문 바로가기
HTML5/SVG

SVG Radial

by Jundol 2015. 6. 9.

* 본 글은 W3SCHOOL.COM 의 SVG 편을 해석 공부한 포스팅입니다.

* 필자의 기준이 절대적인 진리는 아닙니다.



SVG Radial Gradient - <radialGradient>

<radialGradient>태그는 radial 그라디언트를 정의할 때 사용한다.

<radialGradient>태그는 반드시 <defs>태그 내에 위치해야한다. <defs>태그는 정의를 생략하거나 그라디언트와 같이 특별한 요소를 정의할 때 사용한다.


예제 1

방사형(radial) 그라디언트를 원형에 그린다. 색상은 흰색에서 파란색으로 바뀐다.

SVG 코드

<svg height="150" width="500">
  <defs>
    <radialGradient id="grad1" cx="50%" cy="50%" r="50%" fx="50%" fy="50%">
      <stop offset="0%" style="stop-color:rgb(255,255,255);
      stop-opacity:0"
 />
      <stop offset="100%" style="stop-color:rgb(0,0,255);stop-opacity:1" />
    </radialGradient>
  </defs>
  <ellipse cx="200" cy="70" rx="85" ry="55" fill="url(#grad1)" />
</svg>

코드 설명
  • cx , cy , r 속성은 가장 바깥쪽 원형을 정의한다. fx , fy 는 가장 안쪽의 원형을 정의한다.

예제 2
다른 원형을 정의한다.

SVG 코드

<svg height="150" width="500">
  <defs>
    <radialGradient id="grad2" cx="20%" cy="30%" r="30%" fx="50%" fy="50%">
      <stop offset="0%" style="stop-color:rgb(255,255,255);
      stop-opacity:0"
 />
      <stop offset="100%" style="stop-color:rgb(0,0,255);stop-opacity:1" />
    </radialGradient>
  </defs>
  <ellipse cx="200" cy="70" rx="85" ry="55" fill="url(#grad2)" />
</svg>


출처 W3School.com - SVG - SVG Radial

http://www.w3schools.com/svg/svg_grad_radial.asp

'HTML5 > SVG' 카테고리의 다른 글

SVG Editor 분석-2 객체 추가  (0) 2015.06.12
SVG Editor 분석-1 [DOM 구조파악]  (0) 2015.06.10
SVG Linear Gradients  (0) 2015.06.09
SVG Drop Shadows  (0) 2015.06.09
SVG Blur Effects  (0) 2015.06.09

댓글