How to add box-shadow to a svg path circle shape - html

I have this problem, where I need to add box-shadow to a circle, but it seems it is not possible.
Why does it not work or how could I add circle shadow to the </circle> element in SVG path to have the glow effect with current specifications?
/*
circle {
fill: red; <-- works
box-shadow: 0 0 50px red; <-- does not work
}
*/
<svg width="450" height="450">
<path id="motionPath"
d="M 50 200 L 400 200 "
stroke="black" fill="transparent" />
<circle class="circle" r=5 fill=#45b6fe z-index=55>
<animateMotion dur="8s" repeatCount="indefinite" rotate="auto">
<mpath href="#motionPath" />
</animateMotion>
</circle>
</svg>

To add a box-shadow, you will need to work on feGaussianBlur attribute. Below is the code for you and it generates beautiful box-shadow. You can check the output for the same
Note: To see the shadow properly, I have increased the dimension of circle. You can keep as per your requirement.
<svg width="450" height="450">
<defs>
<filter id="f1" x="-40%" y="-40%" width="180%" height="180%" filterUnits="userSpaceOnUse">
<feGaussianBlur in="SourceAlpha" stdDeviation="8"/>
<feOffset dx="5" dy="5" result="offsetblur"/>
<feOffset dx="-5" dy="-5" result="offsetblur"/>
<feMerge>
<feMergeNode/>
<feMergeNode in="SourceGraphic"/>
<feMergeNode in="SourceGraphic"/>
</feMerge>
</filter>
</defs>
<path id="motionPath"
d="M 50 200 L 400 200 "
stroke="black" fill="transparent" />
<circle class="circle" r=10 fill=#45b6fe z-index=55 style="filter: url(#f1);">
<animateMotion dur="8s" repeatCount="indefinite" rotate="auto">
<mpath href="#motionPath" />
</animateMotion>
</circle>
</svg>
UPDATE:
As per your requirement, I have added desired background color to the box shadow.
<svg width="450" height="450">
<defs>
<filter id="f1" x="-40%" y="-30%" width="180%" height="180%" filterUnits="userSpaceOnUse" >
<feColorMatrix result="offsetblur" in="offOut" type="matrix"/>
<feGaussianBlur in="SourceAlpha" stdDeviation="10" />
<feGaussianBlur in="SourceAlpha" stdDeviation="10" result="blur"/>
<feOffset in="blur" dx="5" dy="5" result="offsetBlur" stdDeviation="1.7"/>
<feFlood flood-color="red" flood-opacity="5" result="offsetColor"/>
<feComposite in="offsetColor" in2="offsetBlur" operator="in" result="offsetBlur"/>
<feMerge>
<feMergeNode/>
<feMergeNode in="SourceGraphic"/>
<feMergeNode in="SourceGraphic"/>
</feMerge>
</filter>
</defs>
<path id="motionPath"
d="M 50 200 L 400 200 "
stroke="black" fill="transparent" />
<circle class="circle" r=10 fill=white z-index=55 style="filter: url(#f1);">
<animateMotion dur="8s" repeatCount="indefinite" rotate="auto">
<mpath href="#motionPath" />
</animateMotion>
</circle>
</svg>

so I have this in one of my sites and it works fine for me
.booking-view-tariff-circle > img {
border: 2px solid #fff;
border-radius: 50%;
box-shadow: 2px 2px 4px #000;
display: block;
height: 80px;
width: 80px;
margin-left: auto;
margin-right: auto;
object-fit: cover;
position: relative;
left: -45px;
top: -78px;
box-shadow: 0 8px 8px rgba(0,0,0,0.54);

Related

SVG background-color is not showing in firefoex and safari?

I'm using an svg for my navbar but somehow svg fill color is not showing in firefox or some of the mobile phone?
Here is my svg code:
<svg width="603" height="158" viewBox="0 0 603 158" fill="none" xmlns="http://www.w3.org/2000/svg">
<g filter="url(#filter0_b)">
<path d="M0 0.525391L603 0.525423V0.525423C589.552 0.525403 577.222 8.01149 571.018 19.9432L516.041 125.679C505.715 145.539 485.192 158 462.807 158H0V0.525391Z" fill="#ffffff"/>
<path d="M0.25 0.775391L596.99 0.775423C585.867 2.64133 576.105 9.61836 570.796 19.8278L515.82 125.564C505.536 145.341 485.098 157.75 462.807 157.75H0.25V0.775391Z" stroke="white" stroke-width="0.5"/>
</g>
<defs>
<filter id="filter0_b" x="-10" y="-9.47461" width="623" height="177.475" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feGaussianBlur in="BackgroundImage" stdDeviation="5"/>
<feComposite in2="SourceAlpha" operator="in" result="effect1_backgroundBlur"/>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_backgroundBlur" result="shape"/>
</filter>
</defs>
</svg>
Here is what I want :
I want my svg background color black something like this
But when I open this in Iphone or firefox browser it is showing my background color white?
Here is the image how it is showing in Iphone or firefox
Someone help me out with this issue
Thank You
Hope this will work ..
div{width:600px; height:600px; background: white}
<div><svg width="603" height="158" viewBox="0 0 603 158" fill="none" xmlns="http://www.w3.org/2000/svg">
<g filter="url(#filter0_b)">
<path d="M0 0.525391L603 0.525423V0.525423C589.552 0.525403 577.222 8.01149 571.018 19.9432L516.041 125.679C505.715 145.539 485.192 158 462.807 158H0V0.525391Z" fill="#000000"/>
<path d="M0.25 0.775391L596.99 0.775423C585.867 2.64133 576.105 9.61836 570.796 19.8278L515.82 125.564C505.536 145.341 485.098 157.75 462.807 157.75H0.25V0.775391Z" stroke="white" stroke-width="0.5"/>
</g>
<defs>
<filter id="filter0_b" x="-10" y="-9.47461" width="623" height="177.475" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feGaussianBlur in="BackgroundImage" stdDeviation="5"/>
<feComposite in2="SourceAlpha" operator="in" result="effect1_backgroundBlur"/>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_backgroundBlur" result="shape"/>
</filter>
</defs>
</svg>
</div>

SVG light and shadow a 3D feelling

I want to make an svg looks like it's on 3D by adding a small light in the top and left BORDER and a shadow in the bottom and right BORDER
something like this
#div1 {
background: #ddd;
}
#div1, #div2, #div3 {
width: 100px;
height: 100px;
position: relative;
}
#div2 {
box-shadow: inset -2px -2px 10px 1px #000;
position: absolute;
}
#div3 {
box-shadow: inset 2px 2px 14px 1px #fff;
position: absolute;
}
<div id="div1">
<div id="div2"></div>
<div id="div3"></div>
</div>
But I don't know how to do that with svg filter
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="1000">
<defs>
<filter id="filter1" x="0" y="0">
<feSpecularLighting result="specOut"
specularExponent="20" lighting-color="#bbbbbb">
<fePointLight x="-100" y="-100" z="600"/>
</feSpecularLighting>
<feComposite in="SourceGraphic" in2="specOut"
operator="arithmetic" k1="0" k2="1" k3="1" k4="0"/>
</filter>
</defs>
<path filter="url(#filter1)" fill="#fff" stroke="#000" d="M20,20 L220,20 L220,220 L20,220 L20,20 "></path>
</svg>
Help please and thanks
Firstly, you are trying to light a pure white rectangle with a dim white light. You aren't going to see anything.
If you make the rectangle darker, you'll start to see some effect.
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="300">
<defs>
<filter id="filter1" x="0" y="0">
<feSpecularLighting result="specOut"
specularExponent="20" lighting-color="#bbbbbb">
<fePointLight x="-100" y="-100" z="600"/>
</feSpecularLighting>
<feComposite in="SourceGraphic" in2="specOut"
operator="arithmetic" k1="0" k2="1" k3="1" k4="0"/>
</filter>
</defs>
<path filter="url(#filter1)" fill="#666" stroke="#000" d="M20,20 L220,20 L220,220 L20,220 L20,20 "></path>
</svg>
But in the above example we are only getting gradient of light over our rectangle. How do we make a sort-of bevel edge on the rectangle?
It is important to know that it is not really the RGB channels of an element that determine how the lighting filter components behave. The lighting components treat the alpha component of the colour as a bump map. Varying values of alpha become a topological map that effects the way the pixels are lit.
One way to create varying values of alpha is to use a gaussian blur filter. Here's what that looks like. Note that it is the alpha channel (SourceAlpha) of our shape that we are blurring.
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="300">
<defs>
<filter id="filter2">
<feGaussianBlur in="SourceAlpha" stdDeviation="8" result="blur1"/>
<feBlend in="SourceGraphic" in2="blur1" mode="multiply"/>
</filter>
</defs>
<path filter="url(#filter2)" fill="#666" stroke="#000" d="M20,20 L220,20 L220,220 L20,220 L20,20 "></path>
</svg>
Now if use that blurred alpha channel, we get something close to what you are after.
You can fiddle with the blur, the lighting filter values, and the feComposite values to adjust the effect.
Note that I've also switched to using an feDistantLight here. I think it is more appropriate for this purpose.
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="300">
<defs>
<filter id="filter2">
<feGaussianBlur in="SourceAlpha" stdDeviation="8" result="blur1"/>
<feSpecularLighting result="specOut" in="blur1" specularConstant="1.2" specularExponent="12" lighting-color="#fff">
<feDistantLight azimuth="225" elevation="45"/>
</feSpecularLighting>
<feComposite in="SourceGraphic" in2="specOut" operator="arithmetic" k1="0" k2="1" k3="1" k4="0"/>
</filter>
</defs>
<path filter="url(#filter2)" fill="#666" stroke="#000" d="M20,20 L220,20 L220,220 L20,220 L20,20 "></path>
</svg>
Update
To handle the situation where shapes overlap (see comments), then you will need to clip away any parts of the blur that is outside the shape. You can do that with another feComposite operation.
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="300">
<defs>
<filter id="filter2">
<feGaussianBlur in="SourceAlpha" stdDeviation="8" result="blur1"/>
<feSpecularLighting result="specOut" in="blur1" specularConstant="1.2" specularExponent="12" lighting-color="#fff">
<feDistantLight azimuth="225" elevation="45"/>
</feSpecularLighting>
<feComposite in="SourceGraphic" in2="specOut" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="result"/>
<feComposite operator="atop" in2="SourceGraphic"/>
</filter>
</defs>
<path filter="url(#filter2)" fill="#666" stroke="#000" d="M20,20 L220,20 L220,220 L20,220 L20,20 "></path>
<path filter="url(#filter2)" fill="#666" stroke="#000" d="M40,40 L200,40 L200,110 L40,110 L40,40 "></path>
<path filter="url(#filter2)" fill="#666" stroke="#000" d="M40,120 L200,120 L200,200 L40,200 L40,120 "></path>
</svg>

How to create svg gradient with 3 points set out in a triangle that blend together

<svg id="color-gradient" width="400" height="400" version="1.1" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="gradient" x1="0" x2="0" y1="0" y2="1">
<stop offset="0%" stop-color="red"/>
<stop offset="50%" stop-color="blue" />
<stop offset="100%" stop-color="yellow"/>
</linearGradient>
</defs>
<circle cx="200" cy="200" r="100" fill="url(#gradient)"/>
</svg>
I want to create a svg gradient in a circle that has 3 points of color, set out in a triangle like this.
<svg id="color-gradient" width="400" height="400" version="1.1" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="gradient" x1="0" x2="0" y1="0" y2="1">
<stop offset="0%" stop-color="red"/>
<stop offset="50%" stop-color="blue" />
<stop offset="100%" stop-color="yellow"/>
</linearGradient>
</defs>
<circle cx="200" cy="200" r="100" fill="url(#gradient)"/>
</svg>
I have tried creating a linear Gradient with three stops, but I am not sure how to position the stops where I need them (top left right).
This is about as close as you can get.
svg {
width: 400px;
}
<svg viewBox="0 0 100 100">
<defs>
<filter id="blur" color-interpolation-filters="linear" x="-50%" y="-50%" width="200%" height="200%">
<feGaussianBlur in="SourceGraphic" stdDeviation="9"/>
</filter>
<mask id="circle">
<circle cx="50" cy="50" r="50" fill="white"/>
</mask>
</defs>
<g mask="url(#circle)" filter="url(#blur)">
<rect x="-10" width="110" height="110" fill="blue"/>
<rect x="50" width="60" height="110" fill="yellow"/>
<polygon points="50,50, 60,110, 40,110" fill="#0f8"/>
<polygon points="0,0, 100,0, 100,20, 50,50, 0,20" fill="red"/>
<polygon points="0,10, 50,50, 0,30" fill="#f0f"/>
<polygon points="100,10, 100,30, 50,50" fill="#f80"/>
</g>
</svg>
Since the blending you get in CSS/SVG works purely by combining the red, green, and blue channels of RGB colours separately, it doesn't know that we expect to see green when we blend blue and yellow. Instead you just get a murky grey.
So in the example above, I "cheated" by adding slivers of the "correct" colours in between our three main colours. For example I put a sliver of green between the blue and yellow sectors.
If I don't do that, the above example would look like this:
svg {
width: 400px;
}
<svg viewBox="0 0 100 100">
<defs>
<filter id="blur" color-interpolation-filters="linear" x="-50%" y="-50%" width="200%" height="200%">
<feGaussianBlur in="SourceGraphic" stdDeviation="7"/>
</filter>
<mask id="circle">
<circle cx="50" cy="50" r="50" fill="white"/>
</mask>
</defs>
<g mask="url(#circle)" filter="url(#blur)">
<rect x="-10" width="110" height="110" fill="blue"/>
<rect x="50" width="60" height="110" fill="yellow"/>
<polygon points="0,0, 100,0, 100,20, 50,50, 0,20" fill="red"/>
</g>
</svg>
This topic is inspired by the answer #Paul LeBeau
The author of the question did not ask a question on animation. But I think that the options will be useful to someone.
Gradient rotation
An animation command is added for a group of elements:
circle cx="50" cy="50" r="5" fill="white" stroke="silver">
<animateTransform attributeName="transform" type="rotate" xlink:href="#gr1" dur="2s" values="0 50 50;360 50 50" repeatcount="indefinite"/>
</circle>
<style>
svg {
width: 400px;
}
</style>
<svg viewBox="0 0 100 100">
<defs>
<filter id="blur" color-interpolation-filters="linear" x="-50%" y="-50%" width="200%" height="200%">
<feGaussianBlur in="SourceGraphic" stdDeviation="10"/>
</filter>
<mask id="circle">
<circle cx="50" cy="50" r="50" fill="white">
</circle>
</mask>
</defs>
<g id="gr1" mask="url(#circle)" filter="url(#blur)">
<rect x="-10" width="110" height="110" fill="blue"/>
<rect x="50" width="60" height="110" fill="yellow"/>
<polygon points="50,50, 60,110, 40,110" fill="#0f8"/>
<polygon points="0,0, 100,0, 100,20, 50,50, 0,20" fill="red"/>
<polygon points="0,10, 50,50, 0,30" fill="#f0f"/>
<polygon points="100,10, 100,30, 50,50" fill="#f80"/>
</g>
<circle cx="50" cy="50" r="5" fill="white" stroke="silver">
<animateTransform attributeName="transform" type="rotate" xlink:href="#gr1" dur="2s" values="0 50 50;360 50 50" repeatcount="indefinite"/>
</circle>
</svg>
Animation tracks
The command of animation of the radius of circles is added.
<circle cx="50" cy="50" r="5" fill="none" stroke-width="0.25" stroke="gray" >
<animate id="an1" attributeName="r" values="5;50" dur="2s" begin="0s" repeatcount="indefinite" />
</circle>
<style>
svg {
width: 400px;
}
</style>
<svg viewBox="0 0 100 100">
<defs>
<filter id="blur" color-interpolation-filters="linear" x="-50%" y="-50%" width="200%" height="200%">
<feGaussianBlur in="SourceGraphic" stdDeviation="10"/>
</filter>
<mask id="circle">
<circle cx="50" cy="50" r="50" fill="white">
</circle>
</mask>
</defs>
<g id="gr1" mask="url(#circle)" filter="url(#blur)">
<rect x="-10" width="110" height="110" fill="blue"/>
<rect x="50" width="60" height="110" fill="yellow"/>
<polygon points="50,50, 60,110, 40,110" fill="#0f8"/>
<polygon points="0,0, 100,0, 100,20, 50,50, 0,20" fill="red"/>
<polygon points="0,10, 50,50, 0,30" fill="#f0f"/>
<polygon points="100,10, 100,30, 50,50" fill="#f80"/>
</g>
<circle cx="50" cy="50" r="5" fill="white" stroke="silver">
<animateTransform attributeName="transform" type="rotate" xlink:href="#gr1" dur="2s" values="0 50 50;360 50 50" repeatcount="indefinite"/>
</circle>
<circle cx="50" cy="50" r="5" fill="none" stroke-width="0.25" stroke="gray" >
<animate id="an1" attributeName="r" values="5;50" dur="2s" begin="0s" repeatcount="indefinite" />
</circle>
<circle cx="50" cy="50" r="5" fill="none" stroke-width="0.25" stroke="gray" >
<animate id="an2" attributeName="r" values="5;50" dur="2s" begin="0.5s" repeatcount="indefinite" />
</circle>
<circle cx="50" cy="50" r="5" fill="none" stroke-width="0.25" stroke="gray" >
<animate id="an3" attributeName="r" values="5;50" dur="2s" begin="1s" repeatcount="indefinite" />
</circle>
<circle cx="50" cy="50" r="5" fill="none" stroke-width="0.25" stroke="gray" >
<animate id="an3" attributeName="r" values="5;50" dur="2s" begin="1.5s" repeatcount="indefinite" />
</circle>
<circle cx="50" cy="50" r="5" fill="none" stroke-width="0.25" stroke="gray" >
<animate id="an3" attributeName="r" values="5;50" dur="2s" begin="2s" repeatcount="indefinite" />
</circle>
</svg>
i wanted to give it a try, too.
the result is very different depending on the browser, firefox for example doesn't produce a very good result. (although that is also true for the other solutions, I think)
but it doesn't need the manually inserted composite colors and produces a very homogeneous effect on Safari and Chrome…
<svg viewBox="0 0 100 100">
<defs>
<filter id="colorblend">
<feColorMatrix in="SourceGraphic" result="red" type="matrix" values="
1 0 0 0 0
0 0 0 0 0
0 0 0 0 0
1 0 0 0 0" />
<feColorMatrix in="SourceGraphic" result="green" type="matrix" values="
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 1 0 0 0" />
<feColorMatrix in="SourceGraphic" result="blue" type="matrix" values="
0 0 0 0 0
0 0 0 0 0
0 0 1 0 0
0 0 1 0 0" />
<feGaussianBlur in="red" stdDeviation="20" result="red" />
<feGaussianBlur in="green" stdDeviation="20" result="green" />
<feGaussianBlur in="blue" stdDeviation="20" result="blue" />
<feBlend mode="screen" in="red" in2="green" result="redplusgreen" />
<feBlend mode="screen" in="redplusgreen" in2="blue" result="rainbow" />
<!--fix alpha -->
<feColorMatrix in="rainbow" result="rainbow" type="matrix" values="
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 20 0" />
<!-- increase brightness -->
<feBlend in="rainbow" in2="rainbow" mode="screen" result="rainbow" />
<!-- remove artefacts -->
<feGaussianBlur in="rainbow" stdDeviation="1" />
</filter>
<mask id="mask">
<circle cx="50" cy="50" r="50" fill="white"></circle>
</mask>
</defs>
<g mask="url(#mask)" filter="url(#colorblend)">
<rect x="-10" width="110" height="110" fill="red" />
<rect x="50" width="60" height="110" fill="lime" />
<polygon points="0,0, 100,0, 100,30, 50,50, 0,30" fill="blue" />
</g>
</svg>

SVG Bevel effect for all edges

#logo {
position:relative;
left:20px;
top:20px
}
#logo .container {
height:200px;
width:200px;
top:50px;
left:50px
}
#logo .container, #logo .slice {
position:absolute;
}
#logo .slice {
height:100%;
width:100%;
}
<div id="logo">
<div class="container">
<div class="slice" id="one">
<svg height="200" width="200">
<polygon points="0,200 100,100 200,200" style="fill:green" />
</svg>
</div>
<div class="slice" id="two">
<svg height="200" width="200">
<polygon points="0,0 100,100 0,200" style="fill:blue" />
</svg>
</div>
<div class="slice" id="three">
<svg height="200" width="200">
<polygon points="0,0 100,100 200,0" style="fill:red" />
</svg>
</div>
<div class="slice" id="four">
<svg height="200" width="200">
<polygon points="200,0 100,100 200,200" style="fill:yellow" />
</svg>
</div>
</div>
</div>
I couldn't figure out how to make a bevel filter as in this logo. All three edges of each slice must be equally darker like the light source is projected right above each slice. Briefly, I am expecting an end result exactly the same with the logo in the link.
EDIT:
<svg>
<filter id="inset-shadow">
<feComponentTransfer in=SourceAlpha>
<feFuncA type="table" tableValues="1 0" />
</feComponentTransfer>
<feGaussianBlur stdDeviation="5" />
<feOffset in="offsetblur2" dy="10" result="offsetblur" />
<feOffset dy="-10" result="offsetblur2" />
<feFlood flood-color="rgb(20, 0, 0)" result="color" />
<feComposite in2="offsetblur" operator="in" />
<feComposite in2="SourceAlpha" operator="in" />
<feMerge>
<feMergeNode in="SourceGraphic" />
<feMergeNode />
</feMerge>
</filter>
<polygon points="0,0 100,100 200,0" style="fill:red" filter="url(#inset-shadow)" />
</svg>
Something like this maybe but not enough dark?
Here's a bevel effect using a specular lighting filter:
<svg width="800px" height="600px" viewBox="0 0 200 150"
xmlns="http://www.w3.org/2000/svg" version="1.1">
<defs>
<filter id="MyFilter" height="220%">
<feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/>
<feSpecularLighting in="blur" surfaceScale="5" specularConstant=".75"
specularExponent="30" lighting-color="white"
result="specOut">
<fePointLight x="100" y="75" z="200"/>
</feSpecularLighting>
<feComposite in="specOut" in2="SourceAlpha" operator="in" result="specOut"/>
<feComposite in="SourceGraphic" in2="specOut" operator="arithmetic"
k1="1" k2="1" k3="0" k4="0"/>
</filter>
</defs>
<rect x="1" y="1" width="600" height="800" fill="#888888" stroke="red" />
<g filter="url(#MyFilter)" >
<path fill="#D90000"
d="M60,80 C30,80 30,40 60,40 L140,40 C170,40 170,80 140,80 z" />
</g>
</g>
</svg>
But you can do the same thing more elegantly just using composites and a blur.
<svg width="800px" height="600px" viewBox="0 0 200 150"
xmlns="http://www.w3.org/2000/svg" version="1.1">
<defs>
<filter id="MyFilter" height="220%">
<feFlood flood-color="black"/>
<feComposite operator="out" in2="SourceGraphic"/>
<feGaussianBlur stdDeviation="5"/>
<feComposite operator="atop" in2="SourceGraphic"/>
</filter>
</defs>
<rect x="1" y="1" width="600" height="800" fill="#888888" stroke="red" />
<g filter="url(#MyFilter)" >
<path fill="#D90000"
d="M60,80 C30,80 30,40 60,40 L140,40 C170,40 170,80 140,80 z" />
</g>
</g>
</svg>

SVG drop shadow with filters is truncated

I am trying to make a drop shadow for the following SVG shape:
<svg style="overflow:visible; ">
<defs>
<marker orient="auto" refY="4" refX="2" markerHeight="13" markerWidth="13" id="_x0000_s1094end">
<path style="fill:yellow; " d="M2,2 L2,6 L6,4 L2,2" />
</marker>
</defs>
<path d="M 288,164 L 108,176" style="stroke-width:8; stroke:yellow; marker-end:url(#_x0000_s1094end); " y="4" x="4"/>
</svg>
After the drop shadow the shape is suppossed to look like this (ignore the bits except for the arrow and its shadow):
I tried the following SVG:
<svg style="overflow:visible; ">
<defs>
<marker orient="auto" refY="4" refX="2" markerHeight="13" markerWidth="13" id="_x0000_s1094end">
<path style="fill:yellow; " d="M2,2 L2,6 L6,4 L2,2" />
</marker>
<filter id="f1" x="0" y="0" width="500%" height="500%">
<feOffset result="offOut" in="SourceAlpha" dx="-8" dy="-8" />
<feBlend in="SourceGraphic" in2="offOut" mode="normal" />
</filter>
</defs>
<path d="M 288,164 L 108,176" style="stroke-width:8; stroke:yellow; marker-end:url(#_x0000_s1094end); " y="4" x="4" filter="url(#f1)"/>
</svg>
http://fiddle.jshell.net/md3rT/
What I get is this:
The resulting SVG is coming out truncated.
Also, how can I change the opacity of the shadow?
Thanx in advance!
To stop truncating, just make the filter cover the shape (the drop shadow is above and to the left so the filter needs to cover that region).
<filter id="f1" x="-180%" y="-500%" width="500%" height="1000%">
<feOffset result="offOut" in="SourceAlpha" dx="-8" dy="-8" />
<feBlend in="SourceGraphic" in2="offOut" mode="normal" />
</filter>
If you want the shadow not to be opaque, something involving a non-opaque flood would seem to do the trick. For a general drop shadow you need something like this...
<feGaussianBlur in="alpha-channel-of-feDropShadow-in" stdDeviation="stdDeviation-of-feDropShadow"/>
<feOffset dx="dx-of-feDropShadow" dy="dy-of-feDropShadow" result="offsetblur"/>
<feFlood flood-color="flood-color-of-feDropShadow" flood-opacity="flood-opacity-of-feDropShadow"/>
<feComposite in2="offsetblur" operator="in"/>
<feMerge>
<feMergeNode/>
<feMergeNode in="in-of-feDropShadow"/>
</feMerge>
Although, in Firefox and Chrome you can use the SVG Filter Effects <feDropShadow> filter or a CSS drop-shadow filter instead.
This is what I think you're looking for. It expands the filter region, keeps the drop shadow unblurred and dials the opacity on the shadow down to 50%. (I've also found browsers to get crotchety when you don't provide explicit dimensions for inline SVG.)
<svg x="0px" y="0px" width="500px" height="300px" style="overflow:visible;" viewBox="0 0 500 300">
<defs>
<marker orient="auto" refY="4" refX="2" markerHeight="13" markerWidth="13" id="_x0000_s1094end">
<path style="fill:yellow; " d="M2,2 L2,6 L6,4 L2,2" />
</marker>
<filter id="f1" x="-50%" y="-100%" width="200%" height="400%">
<feOffset result="offOut" in="SourceAlpha" dx="-8" dy="-8" />
<feComponentTransfer>
<feFuncA type="discrete" tableValues="0 .5"/>
</feComponentTransfer>
<feComposite operator="over" in="SourceGraphic"/>
</filter>
</defs>
<path d="M 288,164 L 108,176" style="stroke-width:8; stroke:yellow; marker-end:url(#_x0000_s1094end); " y="4" x="4" filter="url(#f1)"/>
</svg>