Hello everyone! I have recently finished a two-week-long project which has resulted in something that Slick users have (probably) been wanting for quite some time: A much more complete SVG engine. It has decent, if buggy, support for the following features that the old engine lacked:
* Holes in paths, thanks to my path splitter class.
* JavaScript, powered by Mozilla Rhino
* Actual support for SVG path definitions beyond the limited subset that Inkscape uses, including the S, Q, and T tokens and relative values.
* SMIL animation -- supports <animateColor>, <animateTransform>, <animateMotion>, <set>, and event-driven animations.
* Images and text, including SVG fonts and <tspan> elements.
* Everything is stored in a pseudo-DOM tree which is faster than a complete DOM tree but exposes all of the same methods to scripting.
* Groups and <use> elements are actually handled correctly.
* The <polyline> and <circle> elements, which for some reason didn't work before.
* Fill-opacity and stroke-opacity properties.
* Stroke size is actually scaled correctly when the view is zoomed.
* DOM mouse events. (They currently use a lot of CPU power, though.)
* CSS style data specified in <style> tags. Classes and element styles are handled properly.
* Patterns that reference SVG elements, not just images.
* The ability to create many SVGDocumentViewer objects to display multiple SVG documents on one screen. Each viewer has its own translation and scale values, and handles its own events and animations.
You can download the SVG viewer below:
NOTE: SECTOR91.com is currently down, and the link is broken. Sorry about that. It will be back soon.
http://www.sector91.com/resources/downloads/svgview1.0.zip
Unzip the file somewhere, then double-click on svgviewer.jar. You will see the first of my SVG demos, a pendulum animation that is powered by JavaScript (taken from pilat.free.fr but modified). You can scroll around by dragging the middle mouse button or with the arrow keys, and zoom with the mouse wheel or the period and comma keys. You can also enter a file name in the address bar at the top (sorry, URLs don't work yet) and press Enter to view another file. Here's the files that are included with the viewer:
* holetest.svg - Demonstrates holes in polygons. Notice the seam in the center--I haven't figured out how to fix that yet.
* holetest2.svg - Demonstrates multiple holes.
* fonttest.svg - Demonstrates text elements and inline <tspan> elements.
* quad.svg - Demonstrates support for quadratic beizers, and for CSS stylesheets. A W3C demo.
* cubic.svg - Demonstrates more text support, and smooth cubic beizers. A W3C demo.
* motiontest.svg - Modified cubic.svg which demonstrates animateMotion tags.
* anim01.svg - A W3C demo which shows off all major types of animation.
* patterntest.svg - Demonstrates support for patterns. A W3C demo.
* bridge.svg - The bridge of the player's ship from my SVG-powered game,
Project Gamma. An excellent stress test and demonstration of animations and mouse events. Try moving the mouse over the Galaxy Map, and clicking the red buttons.
* undergroundfactory.svg - A cool-looking animation from Project Gamma. Some of the gradients and patterns are missing due to a bug.
You can also copy any other SVG files that you want to test into the program's folder, and then simply enter their names to view them. Be forwarned: this is still buggy, and anything that makes heavy use of complex JavaScript, <use> elements, or animation may fail spectacularly. Most SVG games, toys and such that you can find on the internet don't work at all. This is still very much a work in progress.
If you're wondering where the source code is, I haven't posted it yet because I haven't decided how I want to distribute it. Most of the software from my website has been distributed under a "conditional open-source" license, which requires credit to be given in a blatantly obvious way (like a SECTOR91 logo on a game's main menu screen) in order to use the source code. That would obviously be inconvenient if the source code became a part of Slick, as I expect most people will want it to be. However, I don't just want to give it away without getting credit somehow. I'll have to negotiate this a bit.
Anyway, try out the SVG viewer and don't forget to ask questions if you have some and report bugs if you find any. Just bear in mind that it's incomplete and
will have some bugs.