How can I create the material design shadows in SVG using SVG filters -
i have found this svg creates of shadows works in chrome (firefox , safari on os x not display shadows)
i'm trying reimplement visual of material design in pure svg project , i'm interested in solution follows of design requirements elevation shadows section in material design specs.
i have programatic control on generated svg so, if parameters of filters easier express in computations based on elevation, please specify so.
this comprehensive drop shadow filter structure duplicates functionality of drop shadow control in photoshop. wrote mini-app allow change of these parameters , copy , paste resulting filter: http://codepen.io/mullany/pen/sjopz
<filter id="drop-shadow" color-interpolation-filters="srgb" x="-50%" y="-50%" height="200%" width="200%"> <!-- take source alpha, offset angle/distance , blur size --> <feoffset id="offset" in="sourcealpha" dx="-5.49" dy="-5.11" result="sa-offset"/> <fegaussianblur id="blur" in="sa-offset" stddeviation="4.75" result="sa-o-blur"/> <!-- apply contour using color curve transform on alpha , clipping result input --> <fecomponenttransfer in="sa-o-blur" result="sa-o-b-contin"> <fefunca id="contour" type="table" tablevalues="0 1"/> </fecomponenttransfer> <fecomposite operator="in" in="sa-o-blur" in2="sa-o-b-contin" result="sa-o-b-cont"/> <!-- adjust spread multiplying alpha constant factor --> <fecomponenttransfer in="sa-o-b-cont" result="sa-o-b-c-sprd"> <fefunca id="spread-ctrl" type="linear" slope="2.4"/> </fecomponenttransfer> <!-- adjust color , opacity adding fixed offsets , opacity multiplier --> <fecolormatrix id="recolor" in="sa-o-b-c-sprd" type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 .8 0" result="sa-o-b-c-s-recolor"/> <!-- generate reasonably grainy noise input basefrequency between approx .5 2.0. , add noise k1 , k2 multipliers sum 1 --> <feturbulence result="fnoise" type="fractalnoise" numoctaves="6" basefrequency="1.98"/> <fecolormatrix in="fnoise" type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 7 -3" result="clipnoise"/> <fecomposite id="noisemix" operator="arithmetic" in="sa-o-b-c-s-recolor" in2="clipnoise" k1="0" k2="1" result="sa-o-b-c-s-r-mix"/> <!-- merge shadow original --> <femerge> <femergenode in="sa-o-b-c-s-r-mix"/> <femergenode in="sourcegraphic"/> </femerge> </filter>
Comments
Post a Comment