第三节 SVG 滤镜feblend

2020-04-05  本文已影响0人  CODERLIHAO

in

mode

<svg width="400" height="160">
    <defs>
        <filter id="blend1" x="0" y="0" width="100%" height="100%">
            <feBlend mode="normal" />
        </filter>

        <filter id="blend2" >
            <feImage xlink:href="./09E.png" result="f1" width="100" height="100" ></feImage>
            <feImage xlink:href="./2324.jpg" result="f2" x="175" y="25" width="100" height="100"></feImage>
            <feBlend mode="normal" in="f1" in2="f2"/>
        </filter>

        <pattern id="p1" patternUnits="objectBoundingBox" width=".1" height=".4"
                 patternTransform="rotate(45)" fill-opacity="0.9">
            <rect width="5" height="50" fill="#f00" x="0" y="0" ></rect>
            <rect width="5" height="50" fill="#0f0" x="5" y="0"></rect>
        </pattern>

        <pattern id="p2" patternUnits="objectBoundingBox" width=".1" height=".4"
                 patternTransform="rotate(45)" fill-opacity="0.9">
            <rect width="5" height="50" fill="#0ff" x="0" y="0"></rect>
            <rect width="5" height="50" fill="#00f" x="5" y="0"></rect>
        </pattern>
    </defs>

    <g filter="url(#blend1)">
        <rect width="100" height="100" x="0" y="0" stroke="#000" stroke-width="1" fill="url(#p1)" />
        <rect width="100" height="100" x="25" y="25" stroke="#000" stroke-width="1" fill="url(#p2)" />
    </g>

    <rect x="150" y="0" width="200" height="200"  fill="none" filter="url(#blend2)"></rect>

</svg>
image.png
<svg width="400" height="160">
    <defs>
        <filter id="blend1" x="0" y="0" width="100%" height="100%">
            <feBlend mode="multiply" />
        </filter>

        <filter id="blend2" >
            <feImage xlink:href="./09E.png" result="f1" width="100" height="100" ></feImage>
            <feImage xlink:href="./2324.jpg" result="f2" x="175" y="25" width="100" height="100"></feImage>
            <feBlend mode="multiply" in="f1" in2="f2"/>
        </filter>

        <pattern id="p1" patternUnits="objectBoundingBox" width=".1" height=".4"
                 patternTransform="rotate(45)" fill-opacity="0.9">
            <rect width="5" height="50" fill="#f00" x="0" y="0" ></rect>
            <rect width="5" height="50" fill="#0f0" x="5" y="0"></rect>
        </pattern>

        <pattern id="p2" patternUnits="objectBoundingBox" width=".1" height=".4"
                 patternTransform="rotate(45)" fill-opacity="0.9">
            <rect width="5" height="50" fill="#0ff" x="0" y="0"></rect>
            <rect width="5" height="50" fill="#00f" x="5" y="0"></rect>
        </pattern>
    </defs>

    <g filter="url(#blend1)">
        <rect width="100" height="100" x="0" y="0" stroke="#000" stroke-width="1" fill="url(#p1)" />
        <rect width="100" height="100" x="25" y="25" stroke="#000" stroke-width="1" fill="url(#p2)" />
    </g>
 <rect x="150" y="0" width="200" height="200"  fill="none" filter="url(#blend2)"></rect>
</svg>
image.png
<svg width="400" height="160">
    <defs>
        <filter id="blend1" x="0" y="0" width="100%" height="100%">
            <feBlend mode="screen" />
        </filter>

        <filter id="blend2" >
            <feImage xlink:href="./09E.png" result="f1" width="100" height="100" ></feImage>
            <feImage xlink:href="./2324.jpg" result="f2" x="175" y="25" width="100" height="100"></feImage>
            <feBlend mode="screen" in="f1" in2="f2"/>
        </filter>

        <pattern id="p1" patternUnits="objectBoundingBox" width=".1" height=".4"
                 patternTransform="rotate(45)" fill-opacity="0.9">
            <rect width="5" height="50" fill="#f00" x="0" y="0" ></rect>
            <rect width="5" height="50" fill="#0f0" x="5" y="0"></rect>
        </pattern>

        <pattern id="p2" patternUnits="objectBoundingBox" width=".1" height=".4"
                 patternTransform="rotate(45)" fill-opacity="0.9">
            <rect width="5" height="50" fill="#0ff" x="0" y="0"></rect>
            <rect width="5" height="50" fill="#00f" x="5" y="0"></rect>
        </pattern>
    </defs>
    <g filter="url(#blend1)">
        <rect width="100" height="100" x="0" y="0" stroke="#000" stroke-width="1" fill="url(#p1)" />
        <rect width="100" height="100" x="25" y="25" stroke="#000" stroke-width="1" fill="url(#p2)" />
    </g>
    <rect x="150" y="0" width="200" height="200"  fill="none" filter="url(#blend2)"></rect>
</svg>
image.png
<svg width="400" height="160">
    <defs>
        <filter id="blend1" x="0" y="0" width="100%" height="100%">
            <feBlend mode="darken" />
        </filter>

        <filter id="blend2" >
            <feImage xlink:href="./09E.png" result="f1" width="100" height="100" ></feImage>
            <feImage xlink:href="./2324.jpg" result="f2" x="175" y="25" width="100" height="100"></feImage>
            <feBlend mode="darken" in="f1" in2="f2"/>
        </filter>

        <pattern id="p1" patternUnits="objectBoundingBox" width=".1" height=".4"
                 patternTransform="rotate(45)" fill-opacity="0.9">
            <rect width="5" height="50" fill="#f00" x="0" y="0" ></rect>
            <rect width="5" height="50" fill="#0f0" x="5" y="0"></rect>
        </pattern>

        <pattern id="p2" patternUnits="objectBoundingBox" width=".1" height=".4"
                 patternTransform="rotate(45)" fill-opacity="0.9">
            <rect width="5" height="50" fill="#0ff" x="0" y="0"></rect>
            <rect width="5" height="50" fill="#00f" x="5" y="0"></rect>
        </pattern>
    </defs>
    <g filter="url(#blend1)">
        <rect width="100" height="100" x="0" y="0" stroke="#000" stroke-width="1" fill="url(#p1)" />
        <rect width="100" height="100" x="25" y="25" stroke="#000" stroke-width="1" fill="url(#p2)" />
    </g>
    <rect x="150" y="0" width="200" height="200"  fill="none" filter="url(#blend2)"></rect>
</svg>
image.png
<svg width="400" height="160">
    <defs>
        <filter id="blend1" x="0" y="0" width="100%" height="100%">
            <feBlend mode="lighten" />
        </filter>

        <filter id="blend2" >
            <feImage xlink:href="./09E.png" result="f1" width="100" height="100" ></feImage>
            <feImage xlink:href="./2324.jpg" result="f2" x="175" y="25" width="100" height="100"></feImage>
            <feBlend mode="lighten" in="f1" in2="f2"/>
        </filter>

        <pattern id="p1" patternUnits="objectBoundingBox" width=".1" height=".4"
                 patternTransform="rotate(45)" fill-opacity="0.9">
            <rect width="5" height="50" fill="#f00" x="0" y="0" ></rect>
            <rect width="5" height="50" fill="#0f0" x="5" y="0"></rect>
        </pattern>

        <pattern id="p2" patternUnits="objectBoundingBox" width=".1" height=".4"
                 patternTransform="rotate(45)" fill-opacity="0.9">
            <rect width="5" height="50" fill="#0ff" x="0" y="0"></rect>
            <rect width="5" height="50" fill="#00f" x="5" y="0"></rect>
        </pattern>
    </defs>
    <g filter="url(#blend1)">
        <rect width="100" height="100" x="0" y="0" stroke="#000" stroke-width="1" fill="url(#p1)" />
        <rect width="100" height="100" x="25" y="25" stroke="#000" stroke-width="1" fill="url(#p2)" />
    </g>
    <rect x="150" y="0" width="200" height="200"  fill="none" filter="url(#blend2)"></rect>
</svg>
image.png

参考
https://www.w3.org/TR/SVG11/filters.html#FilterPrimitiveInAttribute
https://en.wikipedia.org/wiki/Blend_modes#Darken_Only

上一篇 下一篇

猜你喜欢

热点阅读