How to do photoshop-like effects in SVG

Forums » Dev.Opera » Archived Article Discussions

This topic has been closed. No new entries allowed.

Reason: You can now post comments on articles on Dev Opera

Forum rules and guidelines

You need to be logged in to post in the forums. If you do not have an account, please sign up first.

29. February 2008, 09:31:46

MacDev_ed

Posts: 16

How to do photoshop-like effects in SVG

Wanna add some polish to your site, the standards way? In this article Erik shows how you can save time and money on creating graphics and effects programmatically using SVG instead of doing them all manually using Photoshop.

( Read the article )

29. February 2008, 15:33:40

freedo

Posts: 110

Hey, this looks very nice!

Thanks for the inspiration, this is really a good example for intelligent use of SVG in modern web pages.

I just noticed two problems with the hover effect (Opera 9.5beta on Linux): The blue highlight ellipse isn't clipped to the button area, and it's above the text, which makes it lesser readable. (The clipping seems to work fine in rsvg, though.)

And then, normally I would use scripting for such simple mouseover effects, but declarative animation. But since Opera is the only browser with quite complete animation support, currently it may be wiser to choose scripting. However, Batik seems to have problems with you script. Maybe you could test it in Batik, too? It's currently one of the best (and strictest) SVG implementations out there, so if it runs in Batik without problems, it should run everywhere.

29. February 2008, 23:21:34

MacDev_ed

Posts: 16

@freedo:
The blue highlight is on top of the text yes, and I see now that's not how the original photoshop-version looked like. Good thing it's so easy to change that in the svg by moving the highlight to before the button text. I think I'll just leave that as an exercise. wink

About the clipping issue in 9.5beta/linux: we'll try to get that fixed for the final version, no worries.

Scripting allowed the svg source to stay a bit cleaner in this case IMHO, declarative animations are sometimes verbose in comparison. I prefer to use declarative animation when I can though.

I did test in Batik 1.7 before publishing the original article, and while it is indeed a very nice SVG implementation it doesn't implement some specifications, in this case the <a href="http://www.w3.org/TR/DOM-Level-2-Style/">DOM Level 2 Style</a> spec, which is used to do the hover effect. You may note that the SVG 1.1 spec requires complete support of DOM Level 2 Style, for more information see <a href="http://www.w3.org/TR/SVG11/svgdom.html#SVGDOMOverview">here</a>. Anyway, sans the hover effect the testcase looked just as good in Batik 1.7 as in Opera 9.

1. March 2008, 21:40:51

freedo

Posts: 110

Thanks for the clarifications!

13. March 2008, 08:43:21

MacDev_ed

Posts: 16

I've made two modifications in the <a href="http://files.myopera.com/MacDev_ed/blog/vistamenu.svg">original example</a>:
1) Made the button text be on top of the blue hover shape
2) Added type="text/css" to the <style> element

That makes it work in FF3 nightlies, and also makes the text more readable.

11. April 2008, 09:57:05

SteveD

Posts: 6

Though this kinda thing is nice for repetitive maintenace and/or localization, I could still do that in Photoshop and code it up in HTML/CSS faster than doing all that code. and it doesn't take long at all to make changes. you just make the changes in photoshop and save it out. how often do navigation bars change that often anyways?

i don't know. as a designer i just feel this is too much work. it's neat that you can generate so much dynamically, but to me it's still faster to do it in photoshop.

21. June 2008, 21:05:11

freedo

Posts: 110

Originally posted by SteveD:

I could still do that in Photoshop and code it up in HTML/CSS faster than doing all that code.



But you don't actually need to code that. SVG editing applications like Inkscape can easily be used to design the actual svg image. You'd only need to add the dynamic parts afterwards.

And this method has one big advantage: the result is a scalable graphic. it looks fine at any resolution.

Originally posted by MacDev_ed:

Scripting allowed the svg source to stay a bit cleaner in this case IMHO, declarative animations are sometimes verbose in comparison.



I just tried a version without scripting. It's easily doable, ads only 7 lines, and I think it's really just a matter of subjective preferences which one to prefer. The scripted version is a bit shorter, the animated one a bit more comprehensible (and faster, I guess?).

26. June 2008, 11:57:32

ahly2018

Posts: 1

how can i do that

30. June 2008, 13:30:53

freedo

Posts: 110

Originally posted by ahly2018:

how can i do that



Hm, do what? ;-)

Forums » Dev.Opera » Archived Article Discussions