{"id":9311,"date":"2022-10-06T04:44:33","date_gmt":"2022-10-06T04:44:33","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=9311"},"modified":"2022-10-06T04:44:33","modified_gmt":"2022-10-06T04:44:33","slug":"svg-filters-intro","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/10\/06\/svg-filters-intro\/","title":{"rendered":"SVG Filters Intro"},"content":{"rendered":"\n<p>Currently,\u00a0CSS\u00a0provides a way to apply color effects to images (e.g., lightness, saturation, contrast, etc.) using the\u00a0filter\u00a0property. However, CSS filters are limited. The effects created with them are usually applicable to images but limited to color manipulation and blurring. To create powerful effects, we\u2019ll need other functions. Such functions are available in\u00a0SVG.<\/p>\n\n\n\n<p>SVG filters add various effects to SVG graphics.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"filter-primitives-2\">Filter Primitives<\/h2>\n\n\n\n<p>In SVG, each &lt;filter&gt; element includes a set of filter elements as its children. Each of such filter primitives performs one basic graphical operation on one or more inputs but outputs only one result. The input is specified in an attribute called&nbsp;in. The result of the operation is specified in the&nbsp;result&nbsp;attribute. The result can then be used as input to other operations. However, if the input is not specified in the&nbsp;in&nbsp;attribute, the result of the previous operation will automatically be used as input. All primitives have the same prefix: fe (a short for \u201cfilter effect\u201d). They are named depending on what an element is or does. E.g., the primitive applying a Gaussian Blur effect to the source graphic is called feGaussianBlur.<\/p>\n\n\n\n<p>Besides using the result of other primitives as input, a filter primitive can also accept other inputs such as SourceGraphic (an element to which the whole filter is applied) and SourceAlpha (the same as SourceGraphic, but this graphic contains only the element\u2019s alpha channel).<\/p>\n\n\n\n<p>Now there are 17 filter primitives that are defined in the\u00a0SVG Filter specification.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"filter-elements-in-svg-4\">Filter Elements in SVG<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Attribute<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>&lt;feBlend&gt;<\/td><td>Blends two objects together using generally used imaging software blending modes.<\/td><\/tr><tr><td>&lt;feColorMatrix&gt;<\/td><td>Applies a matrix transformation.<\/td><\/tr><tr><td>&lt;feComponentTransfer&gt;<\/td><td>Performs component-wise remapping of data.<\/td><\/tr><tr><td>&lt;feComposite&gt;<\/td><td>Performs combination of two input images pixel-wise in image space.<\/td><\/tr><tr><td>&lt;feConvolveMatrix&gt;<\/td><td>Applies a matrix convolution filter effect.<\/td><\/tr><tr><td>&lt;feDiffuseLighting&gt;<\/td><td>Lights an image with the use of the alpha channel as a bump map.<\/td><\/tr><tr><td>&lt;feDisplacementMap&gt;<\/td><td>Uses pixels values from the image from in2 to displace the image from the&nbsp;in&nbsp;attribute.<\/td><\/tr><tr><td>&lt;feFlood&gt;<\/td><td>Creates a rectangle which is filled with the opacity and color values from the flood-opacity and flood-color properties.<\/td><\/tr><tr><td>&lt;feGaussianBlur&gt;<\/td><td>Applies a Gaussian blur on the input image.<\/td><\/tr><tr><td>&lt;feImage&gt;<\/td><td>Refers to a graphic external to this element, that is loaded or rendered into an RGBA raster becoming the result of the primitive.<\/td><\/tr><tr><td>&lt;feMerge&gt;<\/td><td>Blends input image layers.<\/td><\/tr><tr><td>&lt;feMorphology&gt;<\/td><td>Performs &#8220;thinning&#8221; or &#8220;fattening&#8221;.<\/td><\/tr><tr><td>&lt;feOffset&gt;<\/td><td>Offsets the input image.<\/td><\/tr><tr><td>&lt;feSpecularLighting&gt;<\/td><td>Lights a source graphic with the use of the alpha channel as a bump map.<\/td><\/tr><tr><td>&lt;feTile&gt;<\/td><td>Fills a target rectangle with a repeated pattern of an input image.<\/td><\/tr><tr><td>&lt;feTurbulence&gt;<\/td><td>Creates an image with the Perlin turbulence function.<\/td><\/tr><tr><td>&lt;feDistantLight&gt;<\/td><td>Specifies a distant light source which can be used inside a lighting filter primitive.<\/td><\/tr><tr><td>&lt;fePointLight&gt;&gt;<\/td><td>Specifies a light source that allows creating a point light effect.<\/td><\/tr><tr><td>&lt;feSpotLight&gt;<\/td><td>Specifies a light source that allows creating a spotlight effect.<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Currently,\u00a0CSS\u00a0provides a way to apply color effects to images (e.g., lightness, saturation, contrast, etc.) using the\u00a0filter\u00a0property. However, CSS filters are limited. The effects created with them are usually applicable to images but limited to color manipulation and blurring. To create powerful effects, we\u2019ll need other functions. Such functions are available in\u00a0SVG. SVG filters add various [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[574],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/9311"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=9311"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/9311\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=9311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=9311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=9311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}