Movatterモバイル変換


[0]ホーム

URL:


  1. 開発者向けのウェブ技術
  2. SVG
  3. リファレンス
  4. 属性
  5. color-interpolation

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docsコミュニティーについてもっと知り、仲間になるにはこちらから。

View in EnglishAlways switch to English

color-interpolation

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

color-interpolation 属性は、グラデーションの補間、色のアニメーション、アルファ合成に用いる色空間を指定します。

メモ:フィルター効果については、color-interpolation-filters プロパティで用いる色空間を制御します。

color-interpolation プロパティは、色の操作を sRGB 色空間で行うか (光のエネルギーがリニアな) linearized RGB 色空間で行うかを選択します。適切な色空間を選択したら、コンポーネント単位での補間を行います。

子要素が背景と混合されるときは、混合の種類は親要素のcolor-interpolation の値ではなく、子要素のcolor-interpolation プロパティの値によって決まります。href または廃止されたxlink:href 属性で他のグラデーションを参照しているグラデーションでは、fill またはstroke プロパティで直接参照されているグラデーション要素のプロパティの値を用います。色をアニメーションするときは、アニメーションが行われる要素のcolor-interpolation プロパティの値に従って色の補間を行います。

メモ:プレゼンテーション属性であるため、color-interpolation には対応する CSS プロパティcolor-interpolation があります。両方が指定された場合、 CSS プロパティが優先されます。

この属性は、以下の SVG 要素で使用できます。

使用上のメモ

auto |sRGB |linearRGB
デフォルト値sRGB
アニメーション可 (離散)
auto

ユーザーエージェントが色の補間用にsRGB またはlinearRGB 空間を選択してよいことを表します。この値は、作成者が色の補間を特定の色空間で行うことを要求していないことを表します。

sRGB

色の補間を sRGB 色空間で行うべきであることを表します。

linearRGB

色の補間をsRGB の仕様書に記述されている通りのリニア RGB 色空間で行うべきであることを表します。

この例では、4 個の SVG を見せます。それぞれの SVG には、<rect> 要素と、<rect> を塗りつぶすのに用いる異なるグラデーションがあります。最初の 2 個の SVG では<linearGradient> を用い、次の 2 個では<radialGradient> 要素を用います。未対応のブラウザーでは、グラデーションは同じに見えます。

最初の SVG では、<linearGradient> 要素にcolor-interpolation 属性は設定されておらず、デフォルト値のsRGB が用いられます。

svg {  display: block;}
html
<svg width="450" height="70">  <title>    color-interpolation 属性の無い linearGradient の例  </title>  <defs>    <linearGradient>      <stop offset="0%" stop-color="white" />      <stop offset="25%" stop-color="blue" />      <stop offset="50%" stop-color="white" />      <stop offset="75%" stop-color="red" />      <stop offset="100%" stop-color="white" />    </linearGradient>  </defs>  <rect    x="0"    y="0"    width="400"    height="40"    fill="url(#gradientDefault)"    stroke="black" />  <text x="0" y="60" font-family="courier" font-size="16">    color-interpolation 設定なし  </text></svg>

この 2 番目の SVG では、<linearGradient> 要素にcolor-interpolation 属性が設定され、値はlinearRGB になっています。

html
<svg width="450" height="70">  <title>    color-interpolation 属性を用いた linearGradient の例  </title>  <defs>    <linearGradient color-interpolation="linearRGB">      <stop offset="0%" stop-color="white" />      <stop offset="25%" stop-color="blue" />      <stop offset="50%" stop-color="white" />      <stop offset="75%" stop-color="red" />      <stop offset="100%" stop-color="white" />    </linearGradient>  </defs>  <rect    x="0"    y="0"    width="400"    height="40"    fill="url(#gradientLinearRGB)"    stroke="black" />  <text x="0" y="60" font-family="courier" font-size="16">    color-interpolation="linearRGB"  </text></svg>

この 3 番目の SVG では、<radialGradient> 要素にcolor-interpolation 属性は設定されておらず、デフォルト値のsRGB が用いられます。

html
<svg width="450" height="70">  <title>    color-interpolation 属性なしの radialGradient の例  </title>  <defs>    <radialGradient>      <stop offset="0%" stop-color="red" />      <stop offset="100%" stop-color="gold" />    </radialGradient>  </defs>  <rect x="0" y="0" width="400" height="40" fill="url(#none)" stroke="black" />  <text x="0" y="60" font-family="courier" font-size="16">    color-interpolation 設定なし  </text></svg>

この 4 番目の SVG では、<radialGradient> 要素にcolor-interpolation 属性が設定され、値はlinearRGB になっています。

html
<svg width="450" height="70">  <title>    color-interpolation 属性を用いた radialGradient の例  </title>  <defs>    <radialGradient color-interpolation="linearRGB">      <stop offset="0%" stop-color="red" />      <stop offset="100%" stop-color="gold" />    </radialGradient>  </defs>  <rect    x="0"    y="0"    width="400"    height="40"    fill="url(#radLinearRGB)"    stroke="black" />  <text x="0" y="60" font-family="courier" font-size="16">    color-interpolation="linearRGB" (SVG 属性)  </text></svg>

仕様書

Specification
Scalable Vector Graphics (SVG) 2
# ColorInterpolationProperty

ブラウザーの互換性

関連情報

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp