2017-11-07 47 views
0

나는 튜브 전구 빛의 효과를 제공하기 위해 다음과 같이 RadialGradient는을 사용SVG 사각형 및 경로 그라데이션

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" 
    xmlns:xlink="http://www.w3.org/1999/xlink" 
    width="100%" height="100%" 
    viewBox="0 0 100 100"> 

    <radialGradient id="radial" cx="50" cy="50" r="50" 
     gradientUnits="userSpaceOnUse"> 
     <stop offset="0.8" style="stop-color:#00FFFF"/> 
     <stop offset="1" style="stop-color:#004444"/> 
    </radialGradient> 

    <circle cx="50" cy="50" r="50" 
      fill="url(#radial)"/> 
</svg> 

enter image description here

을하지만 사각형 및 경로 그라데이션 또는 사용자 정의 모양의 그라데이션에 대한 동일한 어떻게해야합니까 직사각형이나 별 같은 다른 모양?
Microsoft PowerPoint에서 Rectangular gradient 및 Path Gradient라고하는이 옵션이 있습니다.
위의 효과와 마찬가지로 각 가장자리 선에 대해 중심에서 shud가 시작되고 첫 번째 정지 점 0.8에서 두 번째 정지합니다.

Illustrator에서 이러한 그래디언트를 사용할 수 있습니까?

Rect Star

+0

SVG는 그라디언트를 지원하지 않습니다. –

+0

그림자를 사용하여 가짜를 만들려고 할 수 있습니다. 이것에보십시오 : https://stackoverflow.com/questions/20778568/how-to-make-an-inset-drop-shadow-in-svg – AustinC

+0

@Austin 나는 모든 조합을 가진 밤새 ur 연결에서 전부 시도했다. 아무 것도 이런 효과를 내지 못했습니다. 내 게시물을 수정했습니다. –

답변

3

할 수 있습니다 여러 하위 형태로 모양을 분할하여 그것을 가짜.

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" 
 
    xmlns:xlink="http://www.w3.org/1999/xlink" 
 
    width="100%" height="100%" 
 
    viewBox="0 0 100 100"> 
 

 
    <linearGradient id="horiz" x1="0.5" spreadMethod="reflect"> 
 
     <stop offset="0.8" style="stop-color:#00FFFF"/> 
 
     <stop offset="1" style="stop-color:#004444"/> 
 
    </linearGradient> 
 

 
    <linearGradient id="vert" y1="0.5" x2="0" y2="1" spreadMethod="reflect"> 
 
     <stop offset="0.8" style="stop-color:#00FFFF"/> 
 
     <stop offset="1" style="stop-color:#004444"/> 
 
    </linearGradient> 
 

 
    <polygon points="0,0, 100,100, 100,0, 0,100" fill="url(#horiz)"/> 
 
    <polygon points="0,0, 100,0, 0,100, 100,100" fill="url(#vert)"/> 
 
</svg>

이 작동하는 방식은 우리가 두 개의 모래 시계 모양의 다각형을 가지고, 우리는 각각 선형 그라디언트를 적용 할 것입니다.

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" 
 
    xmlns:xlink="http://www.w3.org/1999/xlink" 
 
    width="100%" height="100%" 
 
    viewBox="0 0 100 100"> 
 

 
    <polygon points="0,0, 100,100, 100,0, 0,100" fill="gold"/> 
 
    <polygon points="0,0, 100,0, 0,100, 100,100" fill="green"/> 
 
</svg>