Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling Shadow of flipped objects #2799

Closed
panthar1 opened this issue Feb 19, 2016 · 13 comments · Fixed by #2854
Closed

Handling Shadow of flipped objects #2799

panthar1 opened this issue Feb 19, 2016 · 13 comments · Fixed by #2854
Assignees
Labels

Comments

@panthar1
Copy link

Hi, I just wanted to report that this exact same issue as Shadow in SVG is displaying in wrong location when the object is rotated #2669, but with how it works with text shadows. I pasted the SVG below that fabric.js gives me. When compared to rsvg, or even the web browser rendering of the SVG, the shadow that fabric.js displays is on the wrong side of the individual characters. This problem applies to both the X and Y offsets when the text is rotated.

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="300" height="300" viewBox="0 0 300 300" xml:space="preserve">
<desc>Created with Fabric.js 1.6.0-rc.1</desc>
<defs></defs>
<filter id="SVGID_5" y="-20%" height="140%" x="-21%" width="142%" >
    <feGaussianBlur in="SourceAlpha" stdDeviation="0"></feGaussianBlur>
    <feOffset dx="10" dy="0" result="oBlur" ></feOffset>
    <feFlood flood-color="rgb(0, 0, 0)"/>
    <feComposite in2="oBlur" operator="in" />
    <feMerge>
        <feMergeNode></feMergeNode>
        <feMergeNode in="SourceGraphic"></feMergeNode>
    </feMerge>
</filter>
    <g transform="translate(459.5 136.23) scale(1.01 1) matrix(-1 0 0 1 0 0) ">
        <text font-family="Times New Roman" font-size="142" font-weight="normal" style="stroke: none; stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: #00ff00; fill-rule: nonzero; opacity: 1;filter: url(#SVGID_5);" >
            <tspan x="-449.5" y="44.73" fill="#00ff00">Some Test Text</tspan>
        </text>
    </g>
</svg>
@asturur
Copy link
Member

asturur commented Feb 19, 2016

Do you think is worth mentioning that your text is flipped?
I think the bug applies to any flipped object, text or shadow.

@asturur asturur added the bug label Feb 19, 2016
@panthar1
Copy link
Author

Sorry, I guess flipped would be the correct word. That's why I included the SVG so you could see the error very easily.

@panthar1 panthar1 changed the title Shadow in SVG is displaying in wrong location when the text is rotated Shadow in SVG is displaying in wrong location when the text is flipped Feb 19, 2016
@asturur asturur self-assigned this Feb 19, 2016
@asturur
Copy link
Member

asturur commented Mar 11, 2016

And now the question... should i flip the shadow on canvas or on the SVG?

Let's talk cleary. Shadow should not scale with object, but we did it because it feels more in line with the scaling effect opposite the resize effect.
So in this way flipping a shadow would be ok.

So let's try a new git hub feature, express your emotion on following posts

animation

@asturur
Copy link
Member

asturur commented Mar 11, 2016

I will flip the shadow on the canvas when the object flip (THIS IS B)

@asturur
Copy link
Member

asturur commented Mar 11, 2016

i will fix the SVG export to do not flip shadow with object, shadow will not flip ( THIS IS A )

@asturur asturur changed the title Shadow in SVG is displaying in wrong location when the text is flipped Shadow of flipped objects is flipped on the svg export Mar 11, 2016
@asturur asturur changed the title Shadow of flipped objects is flipped on the svg export Handling Shadow of flipped objects Mar 11, 2016
@asturur
Copy link
Member

asturur commented Mar 11, 2016

@kangax @Kienz at least you have to vote. :p

@kangax
Copy link
Member

kangax commented Mar 11, 2016

Twitterverse suggested to not flip since changing source of light feels wrong https://twitter.com/kangax/status/708383962834595840

@asturur
Copy link
Member

asturur commented Mar 12, 2016

Completely true, but also scaling shadow is wrong and also borders dropping shadows over the mainshape feels wrong.

Just because flipping is a negative scaling i made this question.

@StephanBijzitter
Copy link
Contributor

Scaling shadow can be explained by raising the distance of the object to the surface. Although that's definitely not the case here, it still could be.

I would say the shadows are based on 0-* light source(s) defined by the user/programmer. Give them an x, y and z value and you're good to go.

@asturur
Copy link
Member

asturur commented Mar 15, 2016

ok for fixing svg export then.

@panthar1
Copy link
Author

Hey Guys,

As someone who is not quite a fabric.js dev, (yet), I would only say the objective of my fun little project is to have a perfect SVG export in every way possible. I am less interested in how it's done, just that what I see on fabric's canvas, I want to look the same in a SVG viewer/browser. So, my 2-cents are, just change the SVG export so things line up wherever possible. This would apply to some of the other issues I have brought up before now to, like with strokes and such. It's not really so much an issue with fabric, as it is, trying to make the SVG export look the same.

@asturur
Copy link
Member

asturur commented Mar 15, 2016

yes fix svg export is the purpouse of this topic.
But you can fix in two way, we are jsut choosing wich one.

@panthar1
Copy link
Author

I know, that's why I injected my opinion that fixing the SVG is probably better :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants