y通道選擇器

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2020 年 1 月⁩ 起,所有主流瀏覽器均已支援。

yChannelSelector 屬性指示 in2 中的哪個顏色通道用於沿 y 軸位移 in 中的畫素。

元素

您可以將此屬性與 <feDisplacementMap> SVG 元素一起使用。

用法說明

R | G | B | A
預設值 A
可動畫的
R

此關鍵字指定將使用 in2 中定義的輸入影像的紅色通道來沿 y 軸位移 in 中定義的輸入影像的畫素。

G

此關鍵字指定將使用 in2 中定義的輸入影像的綠色通道來沿 y 軸位移 in 中定義的輸入影像的畫素。

B

此關鍵字指定將使用 in2 中定義的輸入影像的藍色通道來沿 y 軸位移 in 中定義的輸入影像的畫素。

A

此關鍵字指定將使用 in2 中定義的輸入影像的 alpha 通道來沿 y 軸位移 in 中定義的輸入影像的畫素。

示例

html
<svg viewBox="0 0 440 160" xmlns="http://www.w3.org/2000/svg">
  <filter id="displacementFilter">
    <feImage
      href="mdn.svg"
      x="0"
      y="0"
      width="100%"
      height="100%"
      result="abc" />
    <feDisplacementMap
      in2="abc"
      in="SourceGraphic"
      scale="30"
      yChannelSelector="R" />
  </filter>
  <filter id="displacementFilter2">
    <feImage
      href="mdn.svg"
      x="0"
      y="0"
      width="100%"
      height="100%"
      result="abc" />
    <feDisplacementMap
      in2="abc"
      in="SourceGraphic"
      scale="30"
      yChannelSelector="B" />
  </filter>

  <text x="10" y="60" font-size="50" filter="url(#displacementFilter)">
    Some displaced text
  </text>
  <text x="10" y="120" font-size="50" filter="url(#displacementFilter2)">
    Some displaced text
  </text>
</svg>

規範

規範
濾鏡效果模組第 1 級
# element-attrdef-fedisplacementmap-ychannelselector

瀏覽器相容性