» tagged pages
» logout

sorted by: recent | see : popular
Content Tagged with canvas + svg

The State of SVG Browser Support + Using Flash for SVG in Internet Explorer

As part of the Open Web Advocacy work I've started with Dion and others at Google, one of my goals right now is to help increase awareness and support around doing 2-D/vector graphics on the open web. This includes tools such as the Canvas tag, SVG (Scalable Vector Graphics, an XML markup language for vector graphics), and open source cross-browser drawing toolkits such as Dojo GFX, ExplorerCanvas, and Raphael.

One of the big reasons for this is that 2-D drawing/vector graphics is the top requested feature by double the amount of other feature requests in the recent Open Ajax Alliance Browser Feature Wish List vote-off. As part of this effort I'm doing a bootcamp right now to come up to speed on the latest developments in both Canvas and SVG. I've been using Shelley Powers excellent Painting the Web book to find out the state of vector graphics on the web in 2008. During this education I've run across two interesting things.

First, I wanted to know what the status of SVG support is across the different browsers. I found Jeff Schiller's very complete SVG Test Suite results that are actively kept up to date:

SVG 1.1 became a W3C recommendation on January 13, 2003. Five years later, this page records my results of running various SVG implementations (web browsers and browser plugins) through the official SVG Test Suite. Last updated 2008-06-18.

A screenshot with some of the results:

SVG Test Results Against Browsers for SVG 1.1

SVG Test Results Against Browsers for SVG 1.1

Things are pretty good with Firefox 3, Safari 3, and the winner, Opera. There is a strong subset of SVG that can be used cross-browser with these. Of course, Internet Explorer is the limiting factor here, with a grand score of 0% for all tests:

Internet Explorer SVG Support

Internet Explorer SVG Support

This means that for open web vector graphics to be realistic we need some kind of shim for Internet Explorer (Adobe used to have a browser plugin for IE that had very high quality, but its quite large and was end of lifed in 2007). Internet Explorer actually has an earlier vector graphics standard named VML (Vector Markup Language) that can be used to 'trick' it into having 2-D graphics support that is used by a number of open source toolkits. However, VML can run into some performance issues when you start to get into a large number of nodes and animation with the available open source drawing toolkits.

One natural avenue is to emulate SVG or other 2-D graphics on Internet Explorer using Flash. I had always heard about this possibility but recently found a small company actually doing it to good effect. They have not finished yet, but their demo is impressive:

SVG Render Using Flash

SVG Render Using Flash

Here we are viewing the source of the SVG being rendered by this Flash:

SVG Renderer in Flash (View Source)

SVG Renderer in Flash (View Source)

I emailed the developers to get some more information on this Flash-based renderer and they responded:

Our SVG viewer and editor is not open source. It will be part of the new InputDraw version and with some more features - like draw recognition - will be part of the new Comics Sketch site, so users can create advanced comics strips.

We are part of a small company in Lisbon, Portugal named inEvo that works with a lot of web development, rich interfaces and other areas like computer graphics and artificial intelligence.

While I respect the hard work it took inEvo to create this and their need to charge for it, it looks like using Flash to emulate SVG is a valid approach for Internet Explorer and it would be great to have something similar available open source. Just the basic viewer being available would make sense as open source and would probably even drive more business to them for their higher level tools; it looks like inEvo has created lots of cool things above this that make sense as being commercial-only, such as an SVG editor, drawing recognition, social comics creation and sharing site, etc.

Ajax: Ajaxian

Paint Servers: SVG and Canvas

Robert O'Callahan and Dave Hyatt have been chatting about paint servers as Robert creates SVG ones and then arbitary elements.

This continues the meme of taking common use cases and making them easy via CSS (e.g. reflections).

Here is the SVG version:

HTML:
  1.  
  2. <html xmlns="http://www.w3.org/1999/xhtml"
  3.      xmlns:svg="http://www.w3.org/2000/svg">
  4. h1 { background:url(#h); }
  5. p { background:url(#p); }
  6. span { background:url(#h); }
  7. </style>
  8. </head>
  9.   <h1 style="width:95%;">Heading</h1>
  10.   <p style="width:90%; border:1px solid black; margin-left:2em;">
  11.   "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
  12.   incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
  13.   exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
  14.   irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
  15.   pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia
  16.   deserunt mollit anim id est laborum."
  17.   </p>
  18.   <div style="width:200px;">"Lorem ipsum dolor sit amet,
  19.   <span>consectetur adipisicing elit, sed do eiusmod</span>
  20.   tempor incididunt ut labore et dolore magna aliqua.</div>
  21.   <svg :svg style="height:0">
  22.     </svg><svg :linearGradient id="h" x2="1" y2="0">
  23.       <svg :stop stop-color="yellow" offset="0"/>
  24.       <svg :stop stop-color="yellow" stop-opacity="0" offset="1"/>
  25.     </svg>
  26.     <svg :pattern id="p" patternUnits="userSpaceOnUse"
  27.              x="0" y="0" width="50" height="50"
  28.              viewBox="-1 -1 9 5.5">
  29.       <svg :path d="M 0 0 L 7 0 L 3.5 7 z" fill="red" stroke="blue" opacity="0.3"/>
  30.     </svg>
  31.  
  32. </body>
  33. </html>
  34.  

And here for canvas:

HTML:
  1.  
  2. <!DOCTYPE HTML>
  3. p { background:url(#d); }
  4. </style>
  5. </head>
  6. <body style="background:yellow;">
  7.   <p style="width:60%; border:1px solid black; margin-left:100px;">
  8.   "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
  9.   incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
  10.   exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
  11.   irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
  12.   pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia
  13.   deserunt mollit anim id est laborum."
  14.   </p>
  15.   <canvas id="d" width="50" height="50"></canvas>
  16.     var d = document.getElementById("d");
  17.     var iteration = 0;
  18.     function iterate() {
  19.       ++iteration;
  20.       var ctx = d.getContext("2d");
  21.       ctx.save();
  22.       ctx.clearRect(0, 0, 50, 50);
  23.       ctx.translate(25,25);
  24.       ctx.rotate(Math.PI*iteration/180);
  25.       ctx.fillStyle = "lime";
  26.       ctx.fillRect(-10, -10, 20, 20);
  27.       ctx.restore();
  28.       setTimeout(iterate, 10);
  29.     }
  30.     iterate();
  31.   </script>
  32. </body>
  33. </html>
  34.  

Exciting!

Ajax: Ajaxian

ExplorerCanvas

Google relased a exploer &amp;lt;cavvas&amp;gt; thing!

Firefox: del.icio.us/tag/firefox

New CTM managment in PGF

I have commited a new version with a new CTM (current transformation matrix) managment for shapes.

Now shapes handles matrix and inverse matrix. So it’s really easy to convert points from shape to viewport and from viewport to shape coordinates.

With this, handling missing pick feature in canvas is much more easier. Check this canvas example (Firefox and Safari). You still can play with the SVG/VML version (IE/Firefox/Opera)

In NeoMeeting, I am able now to edit shapes graphically, here is a little screenshot:

Next I will add some shapes like lines and polylines and I will do the first official!

PGF: Xilinus Blog

2D Graphic Framework for Prototype

Here is my first post about a framework I am developing for NeoMeeting. It’s a JavaScript Framework to draw vectorial shapes inside a web page.

The idea comes from dojo.gfx. It gave me the idea to create my own framework, based on Prototype, that fits my needs.

What I need is:
  • OO Framework of course!
  • Pluggable renderer. I want to be able to use SVG or VML (only for IE support of course!) or even Canvas (or anything else that support 2D drawing) with the same code.
  • Have a tools to interact with graphic (like a selection tool)
  • and more (I am sure, but I will found out later :))

I have something running now and I will share with my ideas and code in this blog.

Basically, here is how it works:

Create a simple HTML File with a div that will support graphic rendering
1
2
3

<div id="whiteboard">
</div>
A simple CSS File to set width and height
1
2
3
4
5
6

#whiteboard {
  width:  800px;
  height: 600px;
  float:  left;
} 
Few lines of Javascript to create a renderer and a rectangle.
1
2
3
4
5
6
7
8
9
10
11
12
13
14

// Create an SVG renderer
var renderer = new SVGRenderer("whiteboard");

// Create a rectangle with some attributes like color and bounds
var rect = new Graphic.Rectangle(renderer);
rect.setFill({r: 255, g: 0, b: 0, a: 128});
rect.setStroke({r: 255, g: 255, b: 0, a: 128, w: 5});
rect.setBounds(10, 20, 200, 300);
rect.setRoundCorner(10, 10);
rect.translate(10, 20);
rect.rotate(30);

renderer.add(rect);
As Element functions in Prototype you can chain calls like this
1
2

rect.setFill({r: 255, g: 0, b: 0}).setStroke({r: 255, g: 255, b: 0, a: 128, w: 5});
But for an cleaner HTML layout I will always do one call by line.

Here is what you will see in your page:

Next post, I will detail object graph I have done and share more code.

I think this framework will be open-source and I hope available soon.

PGF: Xilinus Blog

Comet and Vector Graphics with Dojo (dojo.gfx)

better than Comet, a subset of SVG

Dojo: del.icio.us tag dojo

Vitamin Features » Print » Create cross browser vector graphics

como usar graficos vectoriales crossbrowser con dojo ^_^

Dojo: del.icio.us tag dojo

Page 1 | Next >>