Version 19 of SVG

Updated 2010-02-06 09:29:35 by PZ

Scalable vector graphics: "very cool stuff".

The "native" language for scripting SVG--that is, for animating an SVG document by run-time modification of its node tree with SVGDOM--is JavaScript. Steve Ball has been thinking about the desirability of binding Tcl to SVGDOM (perhaps by way of Batik [L1 ] and Jacl?).

tkpath binary extensions supplies many SVG "path" features for native use on Tk canvases - very nice!


RS: Many of SVG's items have a very close correspondence to canvas items, so one might consider using SVG for "serializing" a canvas content to XML, and loading canvas contents from XML... Consider this snippet:

  <polygon fill="yellow" stroke="none"
    points="350 75, 379 161, 469 161, 397 215,
            423 301, 350 250, 277 301, 303 215,
            231 161, 321 161"
    transform="scale(.5)" />

With some string manipulation (and determining the center from the bounding box, for scaling) this could easily be transformed into two canvas commands.


An elaborate canvas to SVG dumper is at http://hem.fyristorg.com/matben/download/can2svg.tcl Dead link Jan. 26/08


Read (svg2can) and write (can2svg) SVG files (in Tcl) are available in Coccinella communication tool.


DKF: SVG is really very close indeed to the Java2D API, and even more especially to the base model used in PostScript and Acrobat (PDF). Not surprising really, given that they all came out of Adobe...


Rolf Ade This is the start of a list of SVG features, that have no native support by the canvas (some of them could eventually be simulated).

  • Text along arcs (or pathes, as the SVG calls it)
  • SVG allows to alter plenty of font properties, for which I found no correspondent in Tcl.
  • SVG allows text to run vertically or right to left.
  • Filter effects.
  • Clipping paths.
  • 'Masking' (transparency effects)

Lars H: Conversely, I've found that SVG seems to lack a counterpart of the -anchor option of a canvas text item, which severely complicates mixing text and graphics. (In the horizontal direction, there is an attribute which does what one wants, although technically it takes its "left" and "right" from the directionality of the text. In the vertical direction there is no direct counterpart; it should in principle be possible to emulate vertical anchoring using baseline alignment and font size changes, but no browser did that correctly.)

AK: IIRC the GTk canvas widget was derived from the Tk Canvas, and enhanced. I believe it does transparency. We might want to have a look at it and see what features we can 'steal' back.


[ Category Graphics ]