大网数据广告活动
Web 标准与前端开发

operator

· 52CE 我爱测

The **`operator`** attribute has two meanings based on the context it's used in. Either it defines the compositing or morphing operation to be performed.

The operator attribute has two meanings based on the context it's used in. Either it defines the compositing or morphing operation to be performed.

You can use this attribute with the following SVG elements:

  • feComposite
  • feMorphology

feComposite

For feComposite, operator defines the compositing operation that is to be performed.

<table class="properties"> <tbody> <tr> <th scope="row">Value</th> <td> <code>over</code> | <code>in</code> | <code>out</code> | <code>atop</code> | <code>xor</code> | <code>lighter</code> | <code>arithmetic</code> </td> </tr> <tr> <th scope="row">Default value</th> <td><code>over</code></td> </tr> <tr> <th scope="row">Animatable</th> <td>Yes</td> </tr> </tbody> </table>

  • over
    • : This value indicates that the source graphic defined in the in attribute is placed over the destination graphic defined in the in2 attribute.
  • in
    • : This value indicates that the parts of the source graphic defined in the in attribute that overlap the destination graphic defined in the in2 attribute, replace the destination graphic.
  • out
    • : This value indicates that the parts of the source graphic defined in the in attribute that fall outside the destination graphic defined in the in2 attribute, are displayed.
  • atop
    • : This value indicates that the parts of the source graphic defined in the in attribute, which overlap the destination graphic defined in the in2 attribute, replace the destination graphic. The parts of the destination graphic that do not overlap with the source graphic stay untouched.
  • xor
    • : This value indicates that the non-overlapping regions of the source graphic defined in the in attribute and the destination graphic defined in the in2 attribute are combined.
  • lighter
    • : This value indicates that the sum of the source graphic defined in the in attribute and the destination graphic defined in the in2 attribute is displayed.
  • arithmetic
    • : This value indicates that the source graphic defined in the in attribute and the destination graphic defined in the in2 attribute are combined using the following formula:

      result = k1*i1*i2 + k2*i1 + k3*i2 + k4

      where: i1 and i2 indicate the corresponding pixel channel values of the input image, which map to in and in2 respectively, and k1, k2, k3, and k4 indicate the values of the attributes with the same name.

feMorphology

For feMorphology, operator defines whether to erode (i.e., thin) or dilate (fatten) the source graphic.

<table class="properties"> <tbody> <tr> <th scope="row">Value</th> <td><code>erode</code> | <code>dilate</code></td> </tr> <tr> <th scope="row">Default value</th> <td><code>erode</code></td> </tr> <tr> <th scope="row">Animatable</th> <td>Yes</td> </tr> </tbody> </table>

  • erode
    • : This value thins the source graphic defined in the in attribute.
  • dilate
    • : This value fattens the source graphic defined in the in attribute.

Example

html,
body,
svg {
  height: 100%;
  font:
    20px "Helvetica",
    "Arial",
    sans-serif;
}
<svg viewBox="0 0 120 70" xmlns="http://www.w3.org/2000/svg">
  <filter id="erode">
    <feMorphology operator="erode" radius="0.4" />
  </filter>
  <filter id="dilate">
    <feMorphology operator="dilate" radius="0.8" />
  </filter>

  <text x="0" y="15">Normal text</text>
  <text x="0" y="40" filter="url(#erode)">Thin text</text>
  <text x="0" y="65" filter="url(#dilate)">Fat text</text>
</svg>

Example

Specifications

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。