2017-06-29 66 views
-1

我需要在給定的svg圓中創建背景顏色,就像下面的圖像一樣。如何使用漸變實現此背景顏色?如何在svg背景中創建漸變顏色

注意:只是該圖片的背景顏色無需針,刻度線和標籤。

enter image description here

示例鏈接:http://jsfiddle.net/mkn9t627/4/

<svg height="500" width="500"> 
    <circle cx="150" cy="150" r="100" stroke="black" stroke-width="3" fill="transparent" /> 
</svg> 
+0

你在談論的背景完全一樣呈現(與t半透明的圈子,以及明亮的亮點)或者只是這三件事中的一件? –

+0

@PaulLeBeau是的,這正是我需要的 –

回答

2

小提琴:https://jsfiddle.net/oLsLdqas/1/

<svg height="250" width="500"> 
    <defs> 
    <radialGradient id="grad1" cx="50%" cy="50%" r="50%" fx="60%" fy="20%"> 
     <stop offset="0%" style="stop-color:rgb(0,0,0);stop-opacity:0" /> 
     <stop offset="100%" style="stop-color:rgb(1,1,1);stop-opacity:1" /> 
    </radialGradient> 
    </defs> 
    <circle cx="180" cy="100" r="100" fill="url(#grad1)" /> 

</svg> 

參見更多信息鏈接:https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Gradients