Code generation fragments dedicated to SVG (Scalable Vector Graphics).
As usual the same namespace is used for a different code generation.
There are no coords for groups.
The can2svg arc code is wrong for Zinc –deployed by SvgDumper.
The code generation is in general split between vgcode (parse) and dumper (compose).
For SVG a different approach is required. The generated SVG is a DOM tree maintained by tDOM.
The second mechanism is well suited for dumper and well handled by »seteach« anyway ;-).
–It might however require some extensions to seteach, will see to it–
Mats Bengtsson uses nested lists for can2svg, so going that way may help to realize synergies.
The nested lists are then put into the DOM–verbatim.
The representation of a window as a svg group requires an rectangle (as background) and clipping.
Group as of TkPath requires TkPath 0.3 or higher. There is no group element before that.
The same applies for windows, mapped onto groups –uses clipping.
A gradient is defined inside the definition section.
Linear Gradient dimension and orientation: x1, x2, y1, y2
Radial Gradients: <radialGradient> ... </radialGradient>
Radial Gradient dimensions and orientation: cx, cy, r, fx, fy
Gradients may inherit attributes from referenced gradients using:
➌. Items, first only the tkpath items are discussed and therefrom pimage is omitted.
ptext in Tkpath, text in Tk text window, ...tablelist.
Straight translation. Similar Tk Canvas rect is simple to translate, by omitting rx and ry.
No direct Tk Canvas equivalent!
Oval cannot be directly translated, the bounding box is to be mapped on rx and ry a ellipse.
polyline in Tkpath, line in Tk.
ppolygon in Tkpath, polygon in Tk.
Ppolygon requires TkPath 0.2.6 or higher.
spline interpolated Tk polygon require a translation identical to »line«. It is thus not feasible.
The TkPath path item can be verbatim translated into a svg path object.
Hence the discussed Tk elements are not covered by the first implementation.
Tk's arc can be translated to an path. –Not clear though from examples inside the
Arc implementation is based on can2svg.tcl.
➍. Transformation Matrix: Only possible for TkPath and Zinc.
The simple transformation elements scale, translate, rotate and skew are not interesting here.
Gradient Transformations are defined as:
Example 4.16. Transformations and Gradients
<linearGradient gradientTransform="matrix( a b c d e f )"
Either as an external reference via CSS, or a property.
In general styles are defined inside a <defs/> section and then referenced via uri.
Important attributes font-size, font-style, font-weight, font-variant, text-decoration, visibility.
¹style do not work that way. Instead use contextual Style Sheets.
pimage in Tkpath, icon in Zinc, image in Tk.
Only jpeg or png are generally supported. Will require tkpng on the Tk side.
FOP isn’t yet able to scale embedded images.
For modified images the »preserveAspectRatio« must be turned off.
See commentary above concerning stipple.
Pattern are used for -tile and -stipple.
lastend, firstend in Zinc, arrow, arrowshape in Tk.
The arrows are implemented as markers and used via marker-start and marker-end.
This is a property of line, arc and curve.
• can2svg.tcl Features code for arrow shapes. This code should be used by svgdumper, too.
base64 does not work well with Img based images. Hence the recommendation is tkpng or Tk 8.6.