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

Shadow in SVG is displaying in wrong location when the object is rotated #2669

Closed
jtweku opened this issue Dec 3, 2015 · 8 comments
Closed
Assignees
Labels

Comments

@jtweku
Copy link

jtweku commented Dec 3, 2015

the SVG generated from shadow for the rotated object is not in the same position as the in canvas. I am assuming that the x and y position of the shadow does not accounted for the angle in the object's shadow.

http://jsfiddle.net/1fgk6qoo/

@jtweku jtweku changed the title Shadow in SVG is displaying in correct location when the object is rotated Shadow in SVG is displaying in wrong location when the object is rotated Dec 3, 2015
@asturur asturur added the bug label Dec 4, 2015
@asturur
Copy link
Member

asturur commented Dec 4, 2015

Omg, i never noticed this. In the canvas the shadow is managed like a shadow, while in svg we emulate it with a filter that makes a copy of the shadow displaced.
We have to change the shadow offset when exporting to svg to take in account of current rotation.

@asturur asturur self-assigned this Dec 4, 2015
@asturur
Copy link
Member

asturur commented Dec 7, 2015

Not a simple fix. i tried couple of hours thinking that rotating shadow offset would help me, but is not that easy. Rotation repeats every 90 degrees and i cannot guess easily the algorithm behind canvas shadow.

@jtweku
Copy link
Author

jtweku commented Dec 7, 2015

I think this should fix it, calculating the rotation modifying the area for the filter to accounted for the rotation.

http://jsfiddle.net/3hnghy3d/

@asturur
Copy link
Member

asturur commented Dec 7, 2015

Yes it does.
I did same thing, just i did not do "360 - angle"
how did you get to that conclusion? why not just angle?

( when angle was not working i then lost myself in terrible calculation searching for some complicated solution including angle of shadow itself and so on...)

@asturur
Copy link
Member

asturur commented Dec 7, 2015

i will make a pr later, so we merge this.

@jtweku
Copy link
Author

jtweku commented Dec 7, 2015

thanks @asturur
I just playing around and notice that after rotating it the value of offset X and offset Y was the opposite. so I figure it must be in the wrong quadrant.

@asturur
Copy link
Member

asturur commented Dec 7, 2015

no it is totally right, i m stupid.

if i rotate the object of x, i have to rotate back the shadow of -x to leave it in its original position.

that's all :)

@asturur
Copy link
Member

asturur commented Dec 8, 2015

closed with latests commit

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

No branches or pull requests

2 participants