LoginSignup
0
2

More than 5 years have passed since last update.

SVGでドロップシャドーの色を変えたい時

Posted at

ガウシアンフィルタの色自体を指定します。

サンプル↓

test.svg

<svg>
    <filter xmlns="http://www.w3.org/2000/svg" id="drop-shadow" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
        <feComponentTransfer in="SourceAlpha">
            <feFuncR type="discrete" tableValues="1"/>
            <feFuncG type="discrete" tableValues="0"/>
            <feFuncB type="discrete" tableValues="0"/>
        </feComponentTransfer>
        <feGaussianBlur stdDeviation="2"/>
        <feOffset dx="0" dy="0" result="shadow"/>
        <feComposite in="SourceGraphic" in2="shadow" operator="over"/>
    </filter>

    <rect width="50" height="50" fill="red" filter="url(#drop-shadow)" />
</svg>


feComponentTransferってやつでRGB値を指定しつつfilterにcolor-interpolation-filtersを付与しましょう。

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2