Monday, March 23rd, 2009

dojo.gfx in detail

Category: Articles, Dojo

Matthew Russell wrote the most in depth article on dojo.gfx that I have seen. It appeared in Linux Journal and has now been re-printed online.

The article runs the gamut. It starts off discussing the place that dojo.gfx lives in the Dojo world:

Then we learn about how gfx abstracts on top of the various underlying graphics subsystems that various browsers expose (Canvas, SVG, VML, Flash, Silverlight, …). gfx will choose for you automatically, or you can ask to use a particular rendered:

  1. <script type="text/javascript"
  2.    djConfig="gfxRenderer:'canvas'"
  3.    src="">
  4. </script>

Then we delve into the drawing API itself:


  1. dojo.addOnLoad(function() {
  2.     var node = dojo.byId("surface");
  3.     var surface = dojox.gfx.createSurface(node, 600, 600);
  5.     rect1 = surface.createRect({
  6.         /* x and y default to (0,0) */
  7.         width : 200,
  8.         height:200
  9.     })
  10.     .setFill("red")
  11.     .setTransform([
  12.         dojox.gfx.matrix.translate(200,200),
  13.         dojox.gfx.matrix.rotategAt(45,100,100)
  14.     ])
  15.     ;
  16. });

From here Matthew covers topics such as manipulating groups, and how you can make areas moveable, and the 2D charting API.

Posted by Dion Almaer at 6:42 am
1 Comment

4.1 rating from 27 votes

1 Comment »

Comments feed TrackBack URI

Small correction: the Flash backend is being worked on but not finished yet, the rest (SVG, VML, Canvas, and Silverlight) are fully operational.

Comment by elazutkin — March 23, 2009

Leave a comment

You must be logged in to post a comment.