简体   繁体   English

SVG渐变色

[英]SVG gradient color

Hi I'm working with SVG here I trying to add the gradient to SVG like this嗨,我在这里使用 SVG 我试图像这样将渐变添加到 SVG 在此处输入图片说明

white and grey gradient but I unable to achieve the desired output.白色和灰色渐变,但我无法实现所需的输出。 Can anyone point me in the right direction.任何人都可以指出我正确的方向。

 <svg viewBox="0 0 400 400"> <defs> <linearGradient id="GradientRepeat" x1="0" y1="1" x2="0" y2="0" spreadMethod="repeat"> <stop offset="0.05" stop-color="#fff" stop-opacity="0"/> <stop offset="1" stop-color="#777" stop-opacity="1"/> </linearGradient> </defs> <circle class="sub-menu-circle" cx="0" cy="200" r="160" fill="url(#GradientRepeat)" /> </svg>

 <svg viewBox="0 0 700 700" class="bubble-svg"> <defs> <linearGradient id="GradientRepeat" x1="0" y1="1" x2="0" y2="0" spreadMethod="repeat" gradientTransform="rotate(170)"> <stop offset="0%" stop-color="#fff" stop-opacity="0"/> <stop offset="10%" stop-color="#bdbdbd" stop-opacity="0.5"/> <stop offset="20%" stop-color="#fff" stop-opacity="0"/> <stop offset="30%" stop-color="#bdbdbd" stop-opacity="0.5"/> <stop offset="40%" stop-color="#fff" stop-opacity="0"/> <stop offset="50%" stop-color="#bdbdbd" stop-opacity="1"/> <stop offset="60%" stop-color="#fff" stop-opacity="0"/> <stop offset="70%" stop-color="#bdbdbd" stop-opacity="0.5"/> <stop offset="80%" stop-color="#bdbdbd" stop-opacity="0"/> <stop offset="100%" stop-color="#fbfbfb" stop-opacity="0.5"/> </linearGradient> </defs> <circle class="sub-menu-circle" cx="0" cy="200" r="160" fill="url(#GradientRepeat)" /> </svg>

Fine-tuning the rendering of shades of gray and white colors depends on which video card, browser and operating system you are using.微调灰色和白色阴影的渲染取决于您使用的视频卡、浏览器和操作系统。

Therefore, I am sending several options.因此,我发送了几个选项。 You can use any option that you prefer or slightly adjust for yourself by changing the colors.您可以使用任何您喜欢的选项,也可以通过更改颜色为自己稍作调整。

 <svg viewBox="0 0 700 700" class="bubble-svg"> <defs> <linearGradient id="GradientRepeat" x1="0" y1="0" x2="0" y2="1" spreadMethod="repeat" gradientTransform="rotate(170)"> <stop offset="0%" stop-color="#B4B4B5" stop-opacity="1"/> <stop offset="17%" stop-color="#fff" stop-opacity="0.8"/> <stop offset="30%" stop-color="#B4B4B5" stop-opacity="0.6"/> <stop offset="49%" stop-color="#fff" stop-opacity="0.8"/> <stop offset="61%" stop-color="#B4B4B5" stop-opacity="0.6"/> <stop offset="80%" stop-color="#fff" stop-opacity="0.8"/> <stop offset="95%" stop-color="#B4B4B5" stop-opacity="1"/> </linearGradient> </defs> <circle class="sub-menu-circle" cx="0" cy="200" r="160" fill="url(#GradientRepeat)" /> </svg>

2# variant 2#变体

 <svg viewBox="0 0 700 700" class="bubble-svg"> <defs> <linearGradient id="GradientRepeat" x1="0" y1="0" x2="0" y2="1" spreadMethod="repeat" gradientTransform="rotate(170)"> <stop offset="0%" stop-color="#B4B4B5" stop-opacity="1"/> <stop offset="17%" stop-color="#F6F6F6" stop-opacity="0.8"/> <stop offset="30%" stop-color="#B4B4B5" stop-opacity="0.6"/> <stop offset="49%" stop-color="#F6F6F6" stop-opacity="0.8"/> <stop offset="61%" stop-color="#B4B4B5" stop-opacity="0.6"/> <stop offset="80%" stop-color="#F6F6F6" stop-opacity="0.8"/> <stop offset="95%" stop-color="#B4B4B5" stop-opacity="1"/> </linearGradient> </defs> <circle class="sub-menu-circle" cx="0" cy="200" r="160" fill="url(#GradientRepeat)" /> </svg>

3# variant 3#变体

 <svg viewBox="0 0 700 700" class="bubble-svg"> <defs> <linearGradient id="GradientRepeat" x1="0" y1="0" x2="0" y2="1" spreadMethod="repeat" gradientTransform="rotate(170)"> <stop offset="0%" stop-color="#ABABAC" stop-opacity="1"/> <stop offset="17%" stop-color="#fff" stop-opacity="0.8"/> <stop offset="30%" stop-color="#ABABAC" stop-opacity="0.6"/> <stop offset="49%" stop-color="#fff" stop-opacity="0.8"/> <stop offset="61%" stop-color="#ABABAC" stop-opacity="0.6"/> <stop offset="80%" stop-color="#fff" stop-opacity="0.8"/> <stop offset="95%" stop-color="#ABABAC" stop-opacity="1"/> </linearGradient> </defs> <circle class="sub-menu-circle" cx="0" cy="200" r="160" fill="url(#GradientRepeat)" /> </svg>

For a more precise adjustment to your taste, it is better to use stop-color and stop-opacity choosing values.为了更精确地调整您的口味,最好使用stop-colorstop-opacity选择值。

Update更新

For the method spreadMethod ="repeat" to start working in your example, you need to reduce the gradient coverage by three times.为了让方法spreadMethod ="repeat"在您的示例中开始工作,您需要将梯度覆盖率减少三倍。 To do this, set x1 ="0" y1 ="0" x2 ="0" y2 ="0.33"为此,请设置x1 ="0" y1 ="0" x2 ="0" y2 ="0.33"
As a result, adjusting the color tones of one wave, we get completely identical copies of it, which facilitates the process compared to the option of a large number of stop-offset结果,调整一个波浪的色调,我们得到它的完全相同的副本,与大量stop-offset的选项相比,这简化了过程

 <svg viewBox="0 0 700 700" class="bubble-svg"> <defs> <linearGradient id="GradientRepeat" x1="0" y1="0" x2="0" y2="0.33" spreadMethod="repeat" gradientTransform="rotate(170)"> <stop offset="10%" stop-color="#ABABAC" stop-opacity="1"/> <stop offset="50%" stop-color="#ffffff" stop-opacity="0.8"/> <stop offset="85%" stop-color="#ABABAC" stop-opacity="1"/> </linearGradient> </defs> <circle class="sub-menu-circle" cx="0" cy="200" r="160" fill="url(#GradientRepeat)" /> </svg>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM