【发布时间】:2018-07-18 03:02:48
【问题描述】:
这是我第一次使用 SVG 图形,我有点困惑……我进行了广泛的研究,但似乎找不到我想要做的事情的答案。
鉴于源图像是彩色图像,我想为图像提供以下外观。
这种效果背后的主要原因是为了克服我的客户可能上传到他们网站的劣质图像(无论是在美观性还是分辨率方面)。
在 Photoshop 中,这是一个渐变贴图和一个在 Mode Multiply 中的透明网格。
我已设法为灰度和“渐变图”应用过滤器,但无法添加网格/图案。
这是我目前的代码:
SVG 文件渐变映射.svg
<svg xmlns="http://www.w3.org/2000/svg">
<filter id="duotone_filter">
<feColorMatrix type="matrix" result="grayscale"
values="1 0 0 0 0
1 0 0 0 0
1 0 0 0 0
0 0 0 1 0" >
</feColorMatrix>
<feComponentTransfer color-interpolation-filters="sRGB" result="duotone">
<feFuncR type="table" tableValues="0.0039525691 0.5764705882"></feFuncR>
<feFuncG type="table" tableValues="0.0123456790 0.8431372549"></feFuncG>
<feFuncB type="table" tableValues="0.0123456790 0.9803921569"></feFuncB>
<feFuncA type="table" tableValues="0 1"></feFuncA>
</feComponentTransfer>
</filter>
</svg>
HTML
<div class="image">
<img src="link/to/file" />
</div>
CSS
.image {
filter: url('../images/gradient-map.svg#duotone_filter');
}
以及图案/填充的 SVG 文件
<svg xmlns="http://www.w3.org/2000/svg" x="0" y="0" width="6px" height="6px" viewBox="0 0 6 6">
<circle cx="3" cy="3" r="2" />
</svg>
这是应该做的事情吗?我应该如何着手达到这个效果?
如果您也可以将我链接到有用的资源,我将不胜感激。我没有找到任何最近的指南或文章。
谢谢。
【问题讨论】:
-
你能从某个地方得到一个透明的网格,比如transparenttextures.com,然后把那个图像和你当前的图像一起加载吗?
-
我可以,但这不是我要找的……
标签: html css svg svg-filters