Svg-gradients
提供:Dev Guides
SVG-グラデーション
グラデーションとは、シェイプ内のある色から別の色へのスムーズな移行を指します。 SVGは2種類のグラデーションを提供します。
- 線形グラデーション-ある方向から別の方向へのある色から別の色への線形遷移を表します。
- 放射状グラデーション-ある方向から別の方向へのある色から別の色への円形の遷移を表します。
線形勾配
宣言
以下は、 <linearGradient> 要素の構文宣言です。 主な属性のみを示しました。
属性
Sr.No. | Name & Description |
---|---|
1 | gradientUnits − units to define the coordinate system for the various length values within the gradient. If gradientUnits="userSpaceOnUse", values represent values in the current user coordinate system in place at the time when the gradient element is used. If patternContentUnits="objectBoundingBox", values represent values in fractions or percentages of the bounding box on the referencing element in place at the time when the gradient element is used. Default is userSpaceOnUse. |
2 | x1 − x-axis co-ordinate of the gradient vector. Defeault is 0. |
3 | y1 − y-axis co-ordinate of the gradient vector. Default is 0. |
4 | x2 − x-axis co-ordinate of the gradient vector. Defeault is 0. |
5 | y2 − y-axis co-ordinate of the gradient vector. Default is 0. |
6 | spreadMethod − indicates method of spreading the gradient within graphics element. Default is 'pad'. |
7 | xlink:href − used to refer to another gradient. |
例
テストVG
- sampleGradientとして定義された1つの<linearGradient>要素。
- linearGradientでは、2つのオフセットが2色で定義されます。
- rect要素、fill属性では、グラデーションのurlが指定され、以前に作成されたグラデーションで四角形を塗りつぶします。
出力
ChromeウェブブラウザでテキストSVGを開きます。 Chrome/Firefox/Operaを使用して、プラグインなしでSVG画像を直接表示できます。 Internet Explorer 9以降もSVG画像レンダリングをサポートしています。
放射状グラデーション
宣言
以下は、 <radialGradient> 要素の構文宣言です。 主な属性のみを示しました。
属性
Sr.No. | Name & Description |
---|---|
1 | gradientUnits − units to define the coordinate system for the various length values within the gradient. If gradientUnits="userSpaceOnUse", values represent values in the current user coordinate system in place at the time when the gradient element is used. If patternContentUnits="objectBoundingBox", values represent values in fractions or percentages of the bounding box on the referencing element in place at the time when the gradient element is used. Default is userSpaceOnUse. |
2 | cx − x-axis co-ordinate of the center of largest circle of gradient vector. Defeault is 0. |
3 | cy − y-axis co-ordinate of the center of largest circle of gradient vector. Default is 0. |
4 | r − radius of the center of largest circle of gradient vector. Defeault is 0. |
5 | fx − focal point of radial gradient. Default is 0. |
6 | fy − focal point of radial gradient. Default is 0. |
7 | spreadMethod − indicates method of spreading the gradient within graphics element. Default is 'pad'. |
8 | xlink:href − used to refer to another gradient. |
例
テストVG
- sampleGradientとして定義された1つの<radialGradient>要素。
- radialGradientでは、2つのオフセットが2色で定義されます。
- rect要素、fill属性では、グラデーションのurlが指定され、以前に作成されたグラデーションで四角形を塗りつぶします。
出力
ChromeウェブブラウザでテキストSVGを開きます。 Chrome/Firefox/Operaを使用して、プラグインなしでSVG画像を直接表示できます。 Internet Explorer 9以降もSVG画像レンダリングをサポートしています。