Svg-filters
提供:Dev Guides
SVG-フィルター
SVGは<filter>要素を使用してフィルターを定義します。 <filter>要素はid属性を使用して一意に識別します。フィルターは<def>要素内で定義され、IDによりグラフィック要素によって参照されます。
SVGは豊富なフィルターセットを提供します。 以下は、一般的に使用されるフィルターのリストです。
- feBlend
- feColorMatrix
- feComponentTransfer
- feComposite
- feConvolveMatrix
- feDiffuseLighting
- feDisplacementMap
- feFlood
- feGaussianBlur
- feImage
- feMerge
- 形態学
- feOffset-ドロップシャドウのフィルター
- feSpecularLighting
- feTile
- feTurbulence
- feDistantLight
- fePointLight
- feSpotLight
宣言
以下は、 <filter> 要素の構文宣言です。 主な属性のみを示しました。
属性
Sr.No. | Name & Description |
---|---|
1 | filterUnits − units to define filter effect region. It specifies the coordinate system for the various length values within the filter and for the attributes defining the filter subregion. If filterUnits="userSpaceOnUse", values represent values in the current user coordinate system in place at the time when the 'filter' element is used. If filterUnits="objectBoundingBox", values represent values in fractions or percentages of the bounding box on the referencing element in place at the time when the 'filter' element is used. Default is userSpaceOnUse. |
2 | primitiveUnits − units to define filter effect region. It specifies the coordinate system for the various length values within the filter and for the attributes defining the filter subregion. If filterUnits="userSpaceOnUse", values represent values in the current user coordinate system in place at the time when the 'filter' element is used. If filterUnits="objectBoundingBox", values represent values in fractions or percentages of the bounding box on the referencing element in place at the time when the 'filter' element is used. Default is userSpaceOnUse. |
3 | x − x-axis co-ordinate of the filter bounding box. Defeault is 0. |
4 | y − y-axis co-ordinate of the filter bounding box. Default is 0. |
5 | width − width of the filter bounding box. Default is 0. |
6 | height − height of the filter bounding box. Default is 0. |
7 | filterRes − numbers representing filter regions. |
8 | xlink:href − used to refer to another filter. |
例
テストVG
- filter1およびfilter2として定義された2つの<filter>要素。
- feGaussianBlurフィルター効果は、stdDeviationを使用して、ぼかし効果でぼかしの量を定義します。
- in = "SourceGraphic"は、効果が要素全体に適用可能であることを定義します。
- feOffsetフィルター効果は、シャドウ効果を作成するために使用されます。 in = "SourceAlpha"は、効果がRGBAグラフィックのアルファ部分に適用可能であることを定義します。
- <rect>要素は、フィルター属性を使用してフィルターをリンクしました。
出力
ChromeウェブブラウザでテキストSVGを開きます。 Chrome/Firefox/Operaを使用して、プラグインなしでSVG画像を直接表示できます。 Internet Explorer 9以降もSVG画像レンダリングをサポートしています。
影付きフィルター
出力
ChromeウェブブラウザでテキストSVGを開きます。 Chrome/Firefox/Operaを使用して、プラグインなしでSVG画像を直接表示できます。 Internet Explorer 9以降もSVG画像レンダリングをサポートしています。