Open In App

SVG operator Attribute

The operator attribute either defines the compositing operation or morphing operation to be performed. The elements that are using this attribute includes: <feComposite> and <feMorphology>.

Syntax:

operator = erode|dilate|over|arithmetic|out|atop|xor|lighter|in

Attribute Values: The operator attribute accepts the values mentioned above and described below



Below examples illustrate the use of operator attribute.

Example 1:






<!DOCTYPE html>
<html>
 
<body>
    <h1 style="color: green;">
        GeeksforGeeks
    </h1>
 
    <svg viewBox="0 0 420 70"
        xmlns="http://www.w3.org/2000/svg">
         
        <filter id="thin">
            <feMorphology operator="erode" radius="0.4" />
        </filter>
 
        <text x="10" y="20" fill="green" filter="url(#thin)">
            Thin text
        </text>
    </svg>
</body>
 
</html>

Output:

Example 2:




<!DOCTYPE html>
<html>
 
<body>
    <h1 style="color: green;">
        GeeksforGeeks
    </h1>
 
    <svg viewBox="0 0 420 70"
        xmlns="http://www.w3.org/2000/svg">
 
        <filter id="fat">
            <feMorphology operator="dilate" radius="0.8" />
        </filter>
 
        <text x="10" y="20" fill="green" filter="url(#fat)">
            Fat text
        </text>
    </svg>
</body>
 
</html>

Output:


Article Tags :