Output graphics to an SVG (scaleable vector graphics) file. More...
Macros | |
#define | vc_svg_group_end(svg) vc_svg_something_end(svg,0) |
Outputs the closing tag to an SVG. More... | |
#define | vc_svg_defs_begin(svg) vc_svg_something_begin("defs",NULL,NULL,NULL,0,svg) |
Outputs a <defs> tag to an SVG. More... | |
#define | vc_svg_defs_end(svg) vc_svg_something_end(svg,0) |
Outputs the closing tag to an SVG. More... | |
#define | vc_svg_marker_end(svg) vc_svg_something_end(svg,0) |
Outputs the closing tag to an SVG. More... | |
#define | vc_svg_clipPath_end(svg) vc_svg_something_end(svg,0) |
Outputs the closing tag to an SVG. More... | |
Functions | |
I32 | vc_svg_init (F32 x0, F32 y0, F32 dx, F32 dy, char *filename, char *addArg, struct _VCSVGOut **svg) |
Opens an SVG file for output. More... | |
I32 | vc_svg_deinit (struct _VCSVGOut **svg) |
Closes an SVG file after opening with vc_svg_init(). More... | |
I32 | vc_svg_group_begin (char *groupname, I8 layerIff1, I8 hideIff1, char *addArg, struct _VCSVGOut *svg) |
Outputs a <group> tag to an SVG. More... | |
I32 | vc_svg_circle (F32 cx, F32 cy, F32 rad, char *colFill, F32 sizeStroke, char *colStroke, char *addArg, struct _VCSVGOut *svg) |
Outputs a circle to an SVG. More... | |
I32 | vc_svg_rect (F32 x0, F32 y0, F32 dx, F32 dy, char *colFill, F32 sizeStroke, char *colStroke, char *addArg, struct _VCSVGOut *svg) |
Outputs a rectangle to an SVG. More... | |
I32 | vc_svg_line (F32 x1, F32 y1, F32 x2, F32 y2, F32 sizeStroke, char *colStroke, char *addArg, struct _VCSVGOut *svg) |
Outputs a line to an SVG. More... | |
I32 | vc_svg_vcline (vcline *l, F32 xMin, F32 yMin, F32 xMax, F32 yMax, F32 sizeStroke, char *colStroke, char *addArg, struct _VCSVGOut *svg) |
Outputs a vcline to an SVG. More... | |
I32 | vc_svg_slc (U16 *rlc, U16 *slc, U16 objNr, F32 sizeObjNr, char *colObjNr, F32 sizeStroke, char *colStroke, char *addArg, struct _VCSVGOut *svg) |
Outputs SLC data to an SVG. More... | |
I32 | vc_svg_text_centered (F32 cx, F32 cy, F32 sizeTextPx, char *colFill, F32 sizeStroke, char *colStroke, char *addArg, struct _VCSVGOut *svg, const char *format,...) |
Outputs a text line to an SVG. More... | |
I32 | vc_svg_text (I32 alignment, F32 cx, F32 cy, F32 sizeTextPx, char *colFill, F32 sizeStroke, char *colStroke, char *addArg, struct _VCSVGOut *svg, const char *format,...) |
Outputs a text line to an SVG. More... | |
I32 | vc_svg_polyline_point (point *lstPt, U32 ptCnt, I8 closeEndIff1, char *colFill, F32 sizeStroke, char *colStroke, char *addArg, struct _VCSVGOut *svg) |
Outputs a polyline to an SVG. More... | |
I32 | vc_svg_polynomial_as_polyline (VCPolynom1D1D *poly, F32 xMin, F32 xMax, U32 posCnt, char *colFill, F32 sizeStroke, char *colStroke, char *addArg, struct _VCSVGOut *svg) |
Outputs a polynomial to an SVG. More... | |
I32 | vc_svg_polyline_projection (U32 *proj, U32 cnt, I32 x0, I32 y0, I32 maxSizePx, I8 verticalIff1, I8 addZeroAtEndsIff1, char *colFill, F32 sizeStroke, char *colStroke, char *addArg, struct _VCSVGOut *svg) |
Outputs Projection data to an SVG. More... | |
I32 | vc_svg_image_link_raw (char *imgFilename, F32 x0, F32 y0, I32 dx, I32 dy, char *addArg, struct _VCSVGOut *svg) |
Links an image to an SVG. More... | |
I32 | vc_svg_doc_view (char *docUnits, F32 cx, F32 cy, F32 zoom, char *addArg, struct _VCSVGOut *svg) |
Outputs a <sodipodi:namedview> tag to an SVG. More... | |
I32 | vc_svg_use (U32 id, F32 x0, F32 y0, char *addArg, struct _VCSVGOut *svg) |
Outputs a <use> tag to an SVG. More... | |
I32 | vc_svg_marker_begin (F32 xRef, F32 yRef, char *addArg, struct _VCSVGOut *svg) |
Outputs a <marker> tag to an SVG. More... | |
I32 | vc_svg_clipPath_begin (char *addArg, struct _VCSVGOut *svg) |
Outputs a <clipPath> tag to an SVG. More... | |
I32 | vc_svg_something_begin (char *something, char *attribs, char *moreAttribs, char *innerText, I8 endIff1, struct _VCSVGOut *svg) |
Outputs a tag to an SVG. More... | |
I32 | vc_svg_something_end (struct _VCSVGOut *svg, I8 suppressLinebreakIff1) |
Outputs a closing tag to an SVG. More... | |
We assume that you are familiar with the SVG standard. The functions here provide easy writeout.
Code Example:
#define vc_svg_group_end | ( | svg | ) | vc_svg_something_end(svg,0) |
This macro of vc_svg_something_end() outputs the closing tag to an SVG.
#define vc_svg_defs_begin | ( | svg | ) | vc_svg_something_begin("defs",NULL,NULL,NULL,0,svg) |
This macro of vc_svg_something_begin() outputsa <defs> tag to an SVG.
#define vc_svg_defs_end | ( | svg | ) | vc_svg_something_end(svg,0) |
This macro of vc_svg_something_end() outputs the closing tag to an SVG.
#define vc_svg_marker_end | ( | svg | ) | vc_svg_something_end(svg,0) |
This macro of vc_svg_something_end() outputs the closing tag to an SVG.
#define vc_svg_clipPath_end | ( | svg | ) | vc_svg_something_end(svg,0) |
This macro of vc_svg_something_end() outputs the closing tag to an SVG.
I32 vc_svg_init | ( | F32 | x0, |
F32 | y0, | ||
F32 | dx, | ||
F32 | dy, | ||
char * | filename, | ||
char * | addArg, | ||
struct _VCSVGOut ** | svg | ||
) |
This function opens an SVG file for output.
x0,y0,dx,dy | Values for the 'viewBox' attribute, you may choose 0,0, img->dx, img->dy. |
filename | Filename for the SVG output. |
addArg | Additional arguments for <svg> tag, set to NULL if not needed. |
svg | The SVG Outputter struct to be initialized. |
0 | on success. |
<0 | on error, especially -1, if file could not be opened for writing. |
I32 vc_svg_deinit | ( | struct _VCSVGOut ** | svg | ) |
This function closes an SVG file after opening with vc_svg_init().
svg | The SVG Outputter struct to be deinitialized and closed. |
0 | on success. |
<0 | on error. |
I32 vc_svg_group_begin | ( | char * | groupname, |
I8 | layerIff1, | ||
I8 | hideIff1, | ||
char * | addArg, | ||
struct _VCSVGOut * | svg | ||
) |
This function outputs a <group> tag to an SVG.
groupname | Name of the group, added as 'inkscape:label' attribute. |
layerIff1 | If set to 1, the attribute 'inkscape:groupmode="layer"' is added. |
hideIff1 | If set to 1, the attribute 'display="none"' is added. |
addArg | Additional arguments for SVG element, set to NULL if not needed. |
svg | The initialized SVG Outputter struct. |
I32 vc_svg_circle | ( | F32 | cx, |
F32 | cy, | ||
F32 | rad, | ||
char * | colFill, | ||
F32 | sizeStroke, | ||
char * | colStroke, | ||
char * | addArg, | ||
struct _VCSVGOut * | svg | ||
) |
This function outputs a circle to an SVG.
cx,cy,rad | Input circle. |
colFill | Fill color, set to NULL if no filling should be applied. |
sizeStroke | Stroke size of line. |
colStroke | Stroke color, set to NULL if no stroke should be visible. |
addArg | Additional arguments for SVG element, set to NULL if not needed. |
svg | The initialized SVG Outputter struct. |
I32 vc_svg_rect | ( | F32 | x0, |
F32 | y0, | ||
F32 | dx, | ||
F32 | dy, | ||
char * | colFill, | ||
F32 | sizeStroke, | ||
char * | colStroke, | ||
char * | addArg, | ||
struct _VCSVGOut * | svg | ||
) |
This function outputs a rectangle to an SVG.
x0,y0,dx,dy | Input rectangle. |
colFill | Fill color, set to NULL if no filling should be applied. |
sizeStroke | Stroke size of line. |
colStroke | Stroke color, set to NULL if no stroke should be visible. |
addArg | Additional arguments for SVG element, set to NULL if not needed. |
svg | The initialized SVG Outputter struct. |
I32 vc_svg_line | ( | F32 | x1, |
F32 | y1, | ||
F32 | x2, | ||
F32 | y2, | ||
F32 | sizeStroke, | ||
char * | colStroke, | ||
char * | addArg, | ||
struct _VCSVGOut * | svg | ||
) |
This function outputs a line to an SVG.
x1,y1,x2,y2 | Input line. |
sizeStroke | Stroke size of line. |
colStroke | Stroke color, set to NULL if no stroke should be visible. |
addArg | Additional arguments for SVG element, set to NULL if not needed. |
svg | The initialized SVG Outputter struct. |
I32 vc_svg_vcline | ( | vcline * | l, |
F32 | xMin, | ||
F32 | yMin, | ||
F32 | xMax, | ||
F32 | yMax, | ||
F32 | sizeStroke, | ||
char * | colStroke, | ||
char * | addArg, | ||
struct _VCSVGOut * | svg | ||
) |
This function outputs a vcline to an SVG.
l | Input line. |
xMin,yMin,xMax,yMax | Bounding rectangle. |
sizeStroke | Stroke size of line. |
colStroke | Stroke color, set to NULL if no stroke should be visible. |
addArg | Additional arguments for SVG element, set to NULL if not needed. |
svg | The initialized SVG Outputter struct. |
I32 vc_svg_slc | ( | U16 * | rlc, |
U16 * | slc, | ||
U16 | objNr, | ||
F32 | sizeObjNr, | ||
char * | colObjNr, | ||
F32 | sizeStroke, | ||
char * | colStroke, | ||
char * | addArg, | ||
struct _VCSVGOut * | svg | ||
) |
This function outputs SLC data to an SVG. If not colObjNr==NULL
, the SVG number will be printed upon the region, which is formed as lines over the pixel regions: sizeStroke
= 1 will fill the region fully, smaller ones make them look like a zebra.
rlc | points to input RLC. |
slc | points to corresponding input SLC. |
objNr | SLC Object number to output, use a loop for all. |
sizeObjNr | SLC Object number label height. |
colObjNr | Color of SLC Object number label, set to NULL for no label. |
sizeStroke | Stroke size of lines, set to 1 for an 'area' look. |
colStroke | Color of the SLC object at the SVG. |
addArg | Additional arguments for SVG element, set to NULL if not needed. |
svg | The initialized SVG Outputter struct. |
I32 vc_svg_text_centered | ( | F32 | cx, |
F32 | cy, | ||
F32 | sizeTextPx, | ||
char * | colFill, | ||
F32 | sizeStroke, | ||
char * | colStroke, | ||
char * | addArg, | ||
struct _VCSVGOut * | svg, | ||
const char * | format, | ||
... | |||
) |
This function outputs a text line to an SVG.
cx,cy | Text position horizontal center. |
sizeTextPx | Font size applied in pixel. |
colFill | Fill color, set to NULL if no filling should be applied. |
sizeStroke | Outline size. |
colStroke | Outline color, set to NULL if no outline should be visible. |
addArg | Additional arguments for SVG element, set to NULL if not needed. |
svg | The initialized SVG Outputter struct. |
format | like at printf(). |
I32 vc_svg_text | ( | I32 | alignment, |
F32 | cx, | ||
F32 | cy, | ||
F32 | sizeTextPx, | ||
char * | colFill, | ||
F32 | sizeStroke, | ||
char * | colStroke, | ||
char * | addArg, | ||
struct _VCSVGOut * | svg, | ||
const char * | format, | ||
... | |||
) |
This function outputs a text line to an SVG.
alignment | <0: start, 0: middle, >0: end. |
cx,cy | Text position horizontal center. |
sizeTextPx | Font size applied in pixel. |
colFill | Fill color, set to NULL if no filling should be applied. |
sizeStroke | Outline size. |
colStroke | Outline color, set to NULL if no outline should be visible. |
addArg | Additional arguments for SVG element, set to NULL if not needed. |
svg | The initialized SVG Outputter struct. |
format | like at printf(). |
I32 vc_svg_polyline_point | ( | point * | lstPt, |
U32 | ptCnt, | ||
I8 | closeEndIff1, | ||
char * | colFill, | ||
F32 | sizeStroke, | ||
char * | colStroke, | ||
char * | addArg, | ||
struct _VCSVGOut * | svg | ||
) |
This function outputs a polyline to an SVG.
lstPt | Input point array. |
cnt | Size of input array. |
closeEndIff1 | Connects last point with first if set to 1. |
colFill | Fill color, set to NULL if no filling should be applied. |
sizeStroke | Stroke size of line. |
colStroke | Stroke color, set to NULL if no stroke should be visible. |
addArg | Additional arguments for SVG element, set to NULL if not needed. |
svg | The initialized SVG Outputter struct. |
I32 vc_svg_polynomial_as_polyline | ( | VCPolynom1D1D * | poly, |
F32 | xMin, | ||
F32 | xMax, | ||
U32 | posCnt, | ||
char * | colFill, | ||
F32 | sizeStroke, | ||
char * | colStroke, | ||
char * | addArg, | ||
struct _VCSVGOut * | svg | ||
) |
This function outputs a polynomial to an SVG using line segments.
poly | Input polynomial. |
xMin,xMax | Value range to be displayed. |
posCnt | Number of points on polynomial which form the line segments. |
colFill | Fill color, set to NULL if no filling should be applied. |
sizeStroke | Stroke size of line. |
colStroke | Stroke color, set to NULL if no stroke should be visible. |
addArg | Additional arguments for SVG element, set to NULL if not needed. |
svg | The initialized SVG Outputter struct. |
I32 vc_svg_polyline_projection | ( | U32 * | proj, |
U32 | cnt, | ||
I32 | x0, | ||
I32 | y0, | ||
I32 | maxSizePx, | ||
I8 | verticalIff1, | ||
I8 | addZeroAtEndsIf1, | ||
char * | colFill, | ||
F32 | sizeStroke, | ||
char * | colStroke, | ||
char * | addArg, | ||
struct _VCSVGOut * | svg | ||
) |
This function outputs array data, for example from projh(), to an SVG. Data is remapped to the interval [0 .. maxSizePx
].
proj | Input array data. |
cnt | Size of input array. |
x0,y0 | Top-left position of data minimum value at first entry. |
maxSizePx | Size from the data minimum to maximum at display. |
verticalIff1 | Data will be presented vertically if set to 1. |
addZeroAtEndsIf1 | Adds a point at the first and last data point, at 0 if set to +1, or at maxSizePx if set to -1, helpful in connection with color filling. |
colFill | Fill color, set to NULL if no filling should be applied. |
sizeStroke | Stroke size of line. |
colStroke | Stroke color, set to NULL if no stroke should be visible. |
addArg | Additional arguments for SVG element, set to NULL if not needed. |
svg | The initialized SVG Outputter struct. |
I32 vc_svg_image_link_raw | ( | char * | imgFilename, |
F32 | x0, | ||
F32 | y0, | ||
I32 | dx, | ||
I32 | dy, | ||
char * | addArg, | ||
struct _VCSVGOut * | svg | ||
) |
This function links an image to an SVG. Set x0
, y0
to -0.5 to centerize for example the center of circles at the pixel square.
imgFilename | Filename relative to the SVG file at any machine. |
x0,y0,dx,dy | Position and size of the image (see description). |
addArg | Additional arguments for SVG element, set to NULL if not needed. |
svg | The initialized SVG Outputter struct. |
I32 vc_svg_doc_view | ( | char * | docUnits, |
F32 | cx, | ||
F32 | cy, | ||
F32 | zoom, | ||
char * | addArg, | ||
struct _VCSVGOut * | svg | ||
) |
This function outputs a <sodipodi:namedview> tag to an SVG.
docUnits | Either "px" or "mm" |
cx,cy | Position where the image view is centered. |
zoom | Zoom level of image view. |
svg | The initialized SVG Outputter struct. |
This function outputs a <use> tag to an SVG. It is needed to refer to objects declared in <defs>.
id | ID of the object to show (usually the positive return value of an vc_svg_..() call). |
x0,y0 | Position where the object is placed to. |
addArg | Additional arguments for SVG element, set to NULL if not needed. |
svg | The initialized SVG Outputter struct. |
This function outputs a <marker> tag to an SVG. It is needed to refer to objects declared in <defs>.
xRef,yRef | Relative position where the marker is placed to. |
addArg | Additional arguments for SVG element, set to NULL if not needed. |
svg | The initialized SVG Outputter struct. |
I32 vc_svg_clipPath_begin | ( | char * | addArg, |
struct _VCSVGOut * | svg | ||
) |
This function outputs a <clipPath> tag to an SVG.
addArg | Additional arguments for SVG element, set to NULL if not needed. |
svg | The initialized SVG Outputter struct. |
I32 vc_svg_something_begin | ( | char * | something, |
char * | attribs, | ||
char * | moreAttribs, | ||
char * | innerText, | ||
I8 | endIff1, | ||
struct _VCSVGOut * | svg | ||
) |
This function outputs a tag to an SVG. It is the core function for the SVG output:
<something
attribs
moreAttribs
id="ID###" (/)>innerText
something | The tag name. |
attribs | Attributes as string. |
moreAttribs | More attributes as string. |
innerText | Text after the closing brace > (endIff1 should not be set to 1). |
endIff1 | If set to 1, the tag is closed: <something .. /> instead of <something ..>..</something> . |
svg | The initialized SVG Outputter struct. |
This function outputs the next valid closing tag to an SVG. It is the core function for the SVG output:
</something
>
svg | The initialized SVG Outputter struct. |
suppressLinebreakIff1 | If set to 1, the closing tag is not at a new line. |
0 | on success. |
<0 | on error. |