Notes on writing a new OpenLaszlo kernel; SVG

I've been interested in SVG (Scalable Vector Graphics) for a long time, and have thought
it would make a good runtime platform for OpenLaszlo applications. With the development of the Legals release, I wanted to see how difficult it would
be to port the DHTML kernel (which is still under development) to SVG. Since Firefox and Opera now support SVG 1.1 natively, it seemed like it was a good time to try this out. SVG is strong on graphics imaging and text rendering, I think of it like a free-software version of Adobe's crown jewels.

With two days of hacking over the weekend, I got a large about of the Sprite API ported to SVG.

Here's a version of the SVG kernel running, try this in Firefox: Try clicking on the gray area of the gray square, the red rect, or the blue rect, or the text string

http://www.beartronics.com/svg/svg.html

source of test LZX app
http://www.beartronics.com/svg/sprite.lzx

Flash version
http://www.beartronics.com/svg/sprite.lzx.swf

This tells me that the kernel API is pretty much on target, certainly for runtimes which have HTML/SVG javascript-like event handling.

I was disappointed to learn that SVG 1.1 (which is what Firefox supports now) does not handle input text or wrapping text regions, however
SVG 1.2 does have these, so I look forward to finishing this work when Firefox SVG 1.2 support is released, and then we will have
an OpenLaszlo runtime with the beautiful imaging model from SVG.

If time permits, I will try to clean up the SVG kernel enough to stick into an upcoming Legals release, so interested people can look at it. I
haven't implemented image or data loading yet, and there's some bugs with background color names and defaults.

SVG has been slow to gain traction, but I think it is one of the best hope for high quality portable graphics, and maybe even rich internet apps that
use them, in the future.

36 Responses to “Notes on writing a new OpenLaszlo kernel; SVG”

  1. gse Says:

    holy crap henry!

  2. Something Witty Goes Here » Blog Archive » SVG News Digest 2006-07-31 Says:

    [...] Henry Minsky contacted me about his work creating a SVG kernel for the OpenLaszlo project. I encouraged him to take make his experiments public. Looks like promising stuff for only two days worth of effort! [...]

  3. stelt Says:

    Very nice, added it to http://svg.startpagina.nl

  4. stelt Says:

    Very nice, added it to http://svg.startpagina.nl/

  5. Le blog de Monsieur Patate» Du Monsieur Patate et du OpenLaszlo Says:

    [...] source: OpenLaszlo Project Blog [...]

  6. » OpenLaszlo tests SVG waters | The Universal Desktop | ZDNet.com Says:

    [...] Over on the OpenLaszlo Weblog, Henry Minsky blogged about testing out a new OpenLaszlo kernal based on Scalable Vector Graphics (SVG). Right now it looks to be a very rough cut, but according to Henry, he is going to see about cleaning it up and adding it to the Legals release which I blogged about earlier. [...]

  7. Robert Yeager Says:

    Everything about OpenLaszlo continues to impress.

    This is wicked cool stuff and only getting better.

  8. » Minsky news: OpenLaszlo and SVG Raju Bitter: OpenLaszlo, Open Ideas, Open Mind Says:

    [...] Henry Minsky took the first steps to genereate SVG out of OpenLaszlo’s programming language LZX. Wow! Never thought that OpenLaszlo could take a next step to SVG. Ryan Stewart of ZDNet has some infos on that, too. And if you don’t know OpenLaszlo checkout Ryan’s article series on building Rich Internet Applications. Laszlo Systems, LZX, OpenLaszlo, svg Web 2.0 [...]

  9. tiago Says:

    Hey,

    http://www.mainada.net/comicssketch/

    In this site, there is a simple implementation o SVG in DrawView.
    All drawings are in SVG format and drawn as such.

    I’ll be very happy and looking forward for this.

  10. jmac Says:

    Howdy,

    A friend of mine pointed me at this post. Very interesting! I’m the head of an open multiplayer game platform called Volity (http://volity.net) and we are very SVG-friendly, encouraging game developers to create their games’ UIs as SVG documents.

    Currently we use the Apache project’s Java-based Batik library in our client application (which we call Gamut), and it is both very complete and very… Java. So I look forward to seeing what direction your work develops in, and offer myself as a source for further SVG advice, especially if it happens to intersect its application in gaming.

  11. Henry Minsky Says:

    I think you could speed up the rendering, tiago, by making use of the new Flash cacheAsBitmap flag for the underlying Flash movieclip used by the OpenLaszlo drawview.

    If you put this in the oninit method for your drawview, it might make rendering faster

    this.getMCRef().cacheAsBitmap = true;

    I don’t know if this will work, but it might. Otherwise Flash redraws the entire view every frame, which gets expensive.

  12. OpenLaszlo Project Blog » Legals PR3: Replacing the tablecloth without touching the place settings Says:

    [...] Further demonstrated the capabilities of the Kernel API by prototyping an SVG kernel in just a few days. [...]

  13. OpenLaszlo News » Mario Jakobs Says:

    [...] The OpenLaszlo Team announced, that they are in time to get the DHTML runtime up and running like described on their roadmap. They are on the right way! Beside, a few weeks ago, they have another entry in the developer blog. Henry Minski wrote a SVG-Kernel for the OpenLaszlo project. So, in the future OpenLaszlo will not bound to flash for output any longer, that´s an important point for many people here in Germany. And they show us that it is possible to provide support for other runtimes as well. Very good work from the OpenLaszlo Team, go on! [...]

  14. Julio Says:

    Adobe was the champion of SVG in a production environment. Soon their viewer will no longer be supported by them, leaving it in limbo. That is unfortunate.
    So my question is, rather than generating SVG, would it make sense to convert SVG to Flash? Another Media Transcoding?

  15. hminsky Says:

    SVG is natively supported now in Firefox and Opera. If Microsoft comes along, then SVG will be the standard web image rendering language and model. We don’t need Adobe anymore.

  16. Jeff Schiller Says:

    Re: SVG to Flash - google for “deng”

  17. Sohbet Says:

    The other big JS gripe is debugging on IE. Nope, sorry, that works really well too

  18. Rajesh Jain Says:

    This is a good start.

    Is the SVG Kernel part of the Legals or can it be downloaded from some place. I am interested in HTML/JavaScript Events on SVG Elements. Is it possible today?

  19. hminsky Says:

    The legals branch has a kind of placeholder SVG kernel in it. It can be invoked by fetching a URL with these query args

    foo.lzx?lzt=svgwrapper&lzr=svg

    Unfortunately I just tried that and it is broken right now, it isn’t including the LFC library for some reason. I will fix it when I get a chance, but I’m kind of overloaded with stuff related to the OL4 release now, so it may need to wait until after we do the release.

    The SVG kernel in there now is only a basic skeleton, and was based on an earlier version of the DHTML kernel, so it needs updating as several things have been improved in the DHTML support.

    Also, there are several issues with SVG which I ran up against, and which I am writing up to send to the SVG developers, which limit the full range of features that can be supported in SVG at this time.

    One modestly important issue is that I cannot see any way in straight SVG to query a loaded bitmap image to find it’s “pixel” dimensions, which many Laszlo apps tend to want to do. You have to know the width and height of your image resources at compile time and specify them on your views. Workarounds would be to have some out-of-band way to get that info via a server or something using data requests.

    The other more serious issue is that there really isn’t good support for input text entry in SVG, nor for querying the runtime for the dimensions of text strings. Hopefully that will be addressed in the future.

  20. hminsky Says:

    But to answer your question, most of the events do work, and they work very close to how the Firefox browser events work. Look at the SVG kernel in WEB-INF/lps/lfc/kernel/svg to see how the events are caught and turned into Laszlo events.

  21. Rajesh Jain Says:

    Thanx, I will check the events model. I believe there was a blog post today on a new HTML Tag in DHTML, I could embedded my SVG content in the HTML tag, and it shows up well. I don’t know if that is the right approach, just another thought.. .

  22. Rajesh Jain Says:

    Hi ,

    I came across the Dojo Tookit, which has the dojo.gfx 2D Vector Graphics API which renders natively to browsers using SVG and VML.

    Can we incorporate/integrate Laszlo Script with Dojo and has there been any proposal to avoid reworks. I will post this on the mailing list as well.

    Thanx!

  23. Jeff Schiller Says:

    To answer the original question, SVG does support a DOM and DOM Events (just like HTML).

    My understanding was that Dojo and Laszlo were already collaborating - hopefully more integration with vector graphics can happen.

    Jeff

  24. Ricardo Says:

    As already mentioned here, SVG has a very important role in the mobile world. Being the company I work for in that area, I’d be very interested to see your work development with the SVG runtime, particularly its support for SVG-T 1.2.
    Thanks!

    Ricardo

  25. James Urquhart Says:

    This example works very well with the Safari 3.0 Beta ( http://www.apple.com/safari/download/ ) which supports SVG 1.1.

    Considering that SVG 1.1 doesn’t seem to support all that you need, it would be interesting to see if you could mix SVG with HTML (as is implied to be possible in a post on the webkit blog, i.e. http://webkit.org/blog/?p=35) and essentially get your missing functionality through the resultant hybrid.

  26. Usb flashdrive Says:

    Thanx, I will check the events model.

  27. Economic Says:

    SVG is natively supported now in Firefox and Opera. If Microsoft comes along, then SVG will be the standard web image rendering language and

  28. Emlaklinkleri Says:

    So my question is, rather than generating SVG, would it make sense to convert SVG to Flash? Another Media Transcoding?

  29. Prestij Says:

    A friend of mine pointed me at this post. Very interesting! I’m the head of an open multiplayer game platform called

  30. Youtube Says:

    You menation about very important subject.

  31. luggage Says:

    I have been wanting to start an open online gaming site, but been having problems with some of the coding. I have heard that they were going to standardize JavaScript. Could this be a problem that I am having? Have they already changed the coding that would be causing me problems with my site? I heard about this one a site a few weeks ago, and have been looking around for a site that could give me some idea when they are going to change over to the new JavaScript. Or even somewhere that could tell me if they have already switched over. Also, could this even be causing a problem with my site and my start up. If anyone has any information on this and could help, I would appreciate it. Thank you all for you time and all the good information.

  32. Frenk Says:

    Earlier this week SiliconBeat lamented the seeming demise of one the key tools in the blogging community: Trackbacks. While I can entirely sympathize with the barage of spam Trackbacks, I too have been forced into a position where by I…

  33. canvas oil paintings Says:

    Interesting! Why don’t you try to include this one to the Wiki intended for SVG User Experiences.

  34. Sohbet Says:

    Thanx, I will check the events model. I believe there was a blog post today on a new HTML Tag in DHTML, I could embedded my SVG content in the HTML tag, and it shows up well. I don’t know if that is the right approach, just another thought..

  35. satılık kiralık emlak Says:

    DOM elements. Was there a reason specifically or some obvious constraint I’m missing? Also, any idea on what document.matchAll() will return in the next generation of browsers? Thanks for the library, we need more devs with your approach.

  36. NBA Says:

    I think everything about OpenLaszlo continues to impress.This is wicked cool stuff and only getting better…


Copyright © 2005-2010 Laszlo Systems, Inc.