斜率
slope 屬性定義了線性濾鏡的值,例如亮度。
slope 屬性受 <feComponentTransfer> 濾鏡基元子元素的支援,包括 feFunc-RGBA 傳輸函式。當傳輸函式的 type 為 linear 時,slope 定義了線性函式的斜率。
當設定 type="linear" 時,您可以將此屬性與以下 SVG 元件傳輸函式元素一起使用。
注意:最初,slope 屬性用於 <font-face> 中,以指示字型的垂直筆畫角度。此用例已棄用。
使用說明
示例
在本示例中,漸變框具有兩個應用了線性濾鏡的文字元素。每個濾鏡的濾鏡傳輸函式的斜率不同。
html
<svg
width="8cm"
height="4cm"
viewBox="0 0 800 400"
xmlns="http://www.w3.org/2000/svg"
version="1.1">
<title>Examples of feComponentTransfer operations</title>
<desc>
Text strings showing the effects of the slope attribute of the
feComponentTransfer filter function linear options.
</desc>
<defs>
<linearGradient
id="MyGradient"
gradientUnits="userSpaceOnUse"
x1="100"
y1="0"
x2="600"
y2="0">
<stop offset="0" stop-color="#ff0000" />
<stop offset="1" stop-color="#0000ff" />
</linearGradient>
<filter
id="Linear1"
filterUnits="objectBoundingBox"
x="0%"
y="0%"
width="100%"
height="100%">
<feComponentTransfer>
<feFuncR type="linear" slope="1" />
<feFuncG type="linear" slope="1" />
<feFuncB type="linear" slope="1" />
</feComponentTransfer>
</filter>
<filter
id="Linear2"
filterUnits="objectBoundingBox"
x="0%"
y="0%"
width="100%"
height="100%">
<feComponentTransfer>
<feFuncR type="linear" slope="0.5" />
<feFuncG type="linear" slope="2.5" />
<feFuncB type="linear" slope="5" />
</feComponentTransfer>
</filter>
</defs>
<rect fill="none" stroke="blue" x="1" y="1" width="798" height="398" />
<g
font-family="Verdana"
font-size="100"
font-weight="bold"
fill="url(#MyGradient)">
<text x="100" y="190" filter="url(#Linear1)">Slope1</text>
<text x="100" y="290" filter="url(#Linear2)">Slope2</text>
</g>
</svg>
規範
| 規範 |
|---|
| 濾鏡效果模組級別 1 # element-attrdef-fecomponenttransfer-slope |
瀏覽器相容性
BCD 表格僅在啟用 JavaScript 的瀏覽器中載入。