{"id":9315,"date":"2022-10-06T04:46:17","date_gmt":"2022-10-06T04:46:17","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=9315"},"modified":"2022-10-06T04:46:17","modified_gmt":"2022-10-06T04:46:17","slug":"svg-drop-shadows","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/10\/06\/svg-drop-shadows\/","title":{"rendered":"SVG Drop Shadows"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"description-of-svg-filters-1\">Description of SVG filters<\/h2>\n\n\n\n<p>All\u00a0SVG filters\u00a0are defined inside a &lt;defs> element. The &lt;defs> element is a short form of definitions. It contains a definition of specific elements like filters. The &lt;filter> element defines an SVG filter. This element has an\u00a0id\u00a0attribute (required) identifying the filter.<\/p>\n\n\n\n<p>To create drop shadows, use the &lt;feOffset&gt; element. You will need to take an SVG graphic and move it in the xy plane.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-svg-lt-feoffset-gt-element-3\">Example of the SVG &lt;feOffset&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;svg width=\"150\" height=\"150\"&gt;\n      &lt;defs&gt;\n        &lt;filter id=\"filter\" x=\"0\" y=\"0\" width=\"150%\" height=\"150%\"&gt;\n          &lt;feOffset result=\"offOut\" in=\"SourceGraphic\" dx=\"30\" dy=\"30\" \/&gt;\n          &lt;feBlend in=\"SourceGraphic\" in2=\"offOut\" mode=\"normal\" \/&gt;\n        &lt;\/filter&gt;\n      &lt;\/defs&gt;\n      &lt;rect width=\"110\" height=\"110\" stroke=\"purple\" stroke-width=\"5\" fill=\"pink\" \n            filter=\"url(#filter)\" \/&gt; \n      Sorry, your browser doesn't support inline SVG.\n    &lt;\/svg&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p>In the above-mentioned example, the &lt;filter&gt; element\u2019s&nbsp;id&nbsp;attribute specifies a unique name for the filter, and the &lt;rect&gt; element\u2019s&nbsp;filter&nbsp;attribute links the element to the &#8220;filter&#8221; filter.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-svg-lt-fegaussianblur-gt-element-6\">Example of the SVG &lt;feGaussianBlur&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;svg width=\"200\" height=\"200\"&gt;\n      &lt;defs&gt;\n        &lt;filter id=\"filter\" x=\"0\" y=\"0\" width=\"250%\" height=\"250%\"&gt;\n          &lt;feOffset result=\"offOut\" in=\"SourceGraphic\" dx=\"30\" dy=\"30\" \/&gt;\n          &lt;feGaussianBlur result=\"blurOut\" in=\"offOut\" stdDeviation=\"10\" \/&gt;\n          &lt;feBlend in=\"SourceGraphic\" in2=\"blurOut\" mode=\"normal\" \/&gt;\n        &lt;\/filter&gt;\n      &lt;\/defs&gt;\n      &lt;rect width=\"150\" height=\"150\" stroke=\"coral\" stroke-width=\"5\" fill=\"pink\" \n            filter=\"url(#filter)\" \/&gt; \n      Sorry, your browser doesn't support inline SVG.\n    &lt;\/svg&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p>Here, it is possible to blur the offset image with the &lt;feGaussianBlur&gt; element. This element\u2019s&nbsp;stdDeviation&nbsp;attribute specifies the amount of blur.<\/p>\n\n\n\n<p>In the following example, the &lt;feOffset&gt; element\u2019s&nbsp;in&nbsp;attribute is changed to &#8220;SourceAlpha&#8221;. It uses the Alpha channel to apply blur instead of the whole RGBA pixel.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-coloring-the-shadow-9\">Example of coloring the shadow:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;svg height=\"200\" width=\"200\"&gt;\n      &lt;defs&gt;\n        &lt;filter id=\"filter\" x=\"0\" y=\"0\" width=\"150%\" height=\"150%\"&gt;\n          &lt;feOffset result=\"offOut\" in=\"SourceAlpha\" dx=\"15\" dy=\"15\" \/&gt;\n          &lt;feGaussianBlur result=\"blurOut\" in=\"offOut\" stdDeviation=\"8\" \/&gt;\n          &lt;feBlend in=\"SourceGraphic\" in2=\"blurOut\" mode=\"normal\" \/&gt;\n        &lt;\/filter&gt;\n      &lt;\/defs&gt;\n      &lt;rect width=\"120\" height=\"120\" stroke=\"purple\" stroke-width=\"5\" fill=\"pink\" \n            filter=\"url(#filter)\" \/&gt; \n       Sorry, your browser doesn't support inline SVG.\n    &lt;\/svg&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p>To transform the colors in the offset image, use the &lt;feColorMatrix&gt; element.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-lt-fecolormatrix-gt-element-12\">Example of the&lt;feColorMatrix&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;svg height=\"200\" width=\"200\"&gt;\n      &lt;defs&gt;\n        &lt;filter id=\"filter\" x=\"0\" y=\"0\" width=\"150%\" height=\"150%\"&gt;\n          &lt;feOffset result=\"offOut\" in=\"SourceGraphic\" dx=\"25\" dy=\"25\" \/&gt;\n          &lt;feColorMatrix result=\"matrixOut\" in=\"offOut\" type=\"matrix\" \n                         values=\"0.2 0 0 0 0 0 0.2 0 0 0 0 0 0.2 0 0 0 0 0 1 0\" \/&gt;\n          &lt;feGaussianBlur result=\"blurOut\" in=\"matrixOut\" stdDeviation=\"9\" \/&gt;\n          &lt;feBlend in=\"SourceGraphic\" in2=\"blurOut\" mode=\"normal\" \/&gt;\n        &lt;\/filter&gt;\n      &lt;\/defs&gt;\n      &lt;rect width=\"150\" height=\"150\" stroke=\"purple\" stroke-width=\"5\" fill=\"lightblue\" \n            filter=\"url(#filter)\" \/&gt; \n       Sorry, your browser doesn't support inline SVG.\n    &lt;\/svg&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Description of SVG filters All\u00a0SVG filters\u00a0are defined inside a &lt;defs> element. The &lt;defs> element is a short form of definitions. It contains a definition of specific elements like filters. The &lt;filter> element defines an SVG filter. This element has an\u00a0id\u00a0attribute (required) identifying the filter. To create drop shadows, use the &lt;feOffset&gt; element. You will need [&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\/9315"}],"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=9315"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/9315\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=9315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=9315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=9315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}