[Output Generation] Support gradients in xdot output
Ported Issue from Mantis Original ID: 2315 Reported By: ryandesign
SEVERITY: FEATURE Submitted: 2013-07-29 06:39:25
Currently, gradients are not reflected in xdot output, but I'd like them to be. I need to know the start and end points (and for radial gradients, the start and end radii) and for each color stop, the percentage along the line and the color value at that point.
Two possible implementations occur to me:
- The gradient information could be encoded in the existing "C" and "c" fill and pen color commands, for example using the CSS gradient specifications:
The advantage of method (1) would be not needing to add new commands to XDOT. The disadvantage is that existing renderers are unlikely to be able to use those colors without needing to parse them.
- Alternately, new commands could be invented (e.g. "G" (linear gradient fill), "g" (linear gradient pen), "R" (radial gradient fill), "r" (radial gradient pen)) and you could invent a syntax for communicating the positions and color stops. For example:
G x1 y1 x2 y2 n [p m -b1b2...bn] Set fill linear gradient, along a line from x1,y1 to x2,y2, with n color stops. For each color stop at position p, the color value consists of the m bytes following '-'. (The values in square brackets repeat n times.)
R x1 y1 r1 x2 y2 r2 n [p m -b1b2...bn] Set fill radial gradient, starting from a circle centered at x1,y1 with radius r1, ending at a circle centered at x2,y2 with radius r2, with n color stops. For each color stop at position p, the color value consists of the m bytes following '-'. (The values in square brackets repeat n times.)
The advantage of method (2) would be that you could provide a solid color fallback for renderers that can't do gradients, and any renderer that wants to do gradients can easily acquire all the required parameters without needing to do any further parsing of a color string other than the already-required parsing of the XDOT draw commands.
If new commands are added to XDOT, I would recommend increasing the xdotversion to 1.3, as was done previously when the "I" command was added in xdotversion 1.2.