TPCCLIB
Loading...
Searching...
No Matches
svg_defs.c File Reference

Defined objects for TPC SVG C library. More...

#include "libtpcsvg.h"

Go to the source code of this file.

Functions

char * svgColorName (const svgColor i)
char * svgSymbolName (const svgSymbolType i)
int svg_define_symbols (FILE *fp, char *errmsg, int verbose)

Variables

int SVG_INLINE

Detailed Description

Defined objects for TPC SVG C library.

Author
Vesa Oikonen

Definition in file svg_defs.c.

Function Documentation

◆ svg_define_symbols()

int svg_define_symbols ( FILE * fp,
char * errmsg,
int verbose )

Define the curve symbols for SVG graphics file.

See also
svgSymbolName, svgColorName
Returns
Returns 0 if successful, <>0 in case of error.
Parameters
fpSVG graphics file pointer.
errmsgChar pointer to string (at least of length 128) where possible error description is copied; set to NULL if not necessary.
verboseVerbose level; if zero, then nothing is printed to stderr or stdout.

Definition at line 83 of file svg_defs.c.

91 {
92 char tmp[2048], ilc[9], line[256], allsame[128];
93
94 if(verbose>0) printf("svg_define_symbols(fp, errmsg, %d)\n", verbose);
95
96 if(SVG_INLINE) strcpy(ilc, "svg:"); else strcpy(ilc, "");
97 strcpy(allsame, "viewBox=\"0 0 120 120\" preserveAspectRatio=\"xMinYMin meet\"");
98
99 strcpy(tmp, "");
100 sprintf(line, " <%sdefs>\n", ilc); strcat(tmp, line);
101
102 sprintf(line, " <%ssymbol id=\"sym-rect\" %s >\n", ilc, allsame);
103 strcat(tmp, line);
104 //sprintf(line, " <%srect x=\"2\" y=\"2\" width=\"116\" height=\"116\" style=\"stroke-width:40\" />\n", ilc);
105 sprintf(line, " <%spolygon points=\"13 13, 13 107, 107 107, 107 13\" />\n", ilc);
106 strcat(tmp, line);
107 sprintf(line, " </%ssymbol>\n", ilc); strcat(tmp, line);
108
109 sprintf(line, " <%ssymbol id=\"sym-circ\" %s >\n", ilc, allsame);
110 strcat(tmp, line);
111// sprintf(line, " <%scircle cx=\"60\" cy=\"60\" r=\"50\" />\n", ilc);
112 sprintf(line, " <%scircle cx=\"60\" cy=\"60\" r=\"46\" />\n", ilc);
113 strcat(tmp, line);
114 sprintf(line, " </%ssymbol>\n", ilc); strcat(tmp, line);
115
116 sprintf(line, " <%ssymbol id=\"sym-uptr\" %s >\n", ilc, allsame);
117 strcat(tmp, line);
118// sprintf(line, " <%spolygon points=\" 10 17, 110 17, 60 103 \" />\n", ilc);
119 sprintf(line, " <%spolygon points=\" 14 14, 106 14, 60 106 \" />\n", ilc);
120 strcat(tmp, line);
121 sprintf(line, " </%ssymbol>\n", ilc); strcat(tmp, line);
122
123 sprintf(line, " <%ssymbol id=\"sym-dotr\" %s >\n", ilc, allsame);
124 strcat(tmp, line);
125// sprintf(line, " <%spolygon points=\" 10 103, 110 103, 60 17 \" />\n", ilc);
126 sprintf(line, " <%spolygon points=\" 14 106, 106 106, 60 14 \" />\n", ilc);
127 strcat(tmp, line);
128 sprintf(line, " </%ssymbol>\n", ilc); strcat(tmp, line);
129
130 sprintf(line, " <%ssymbol id=\"sym-letr\" %s >\n", ilc, allsame);
131 strcat(tmp, line);
132// sprintf(line, " <%spolygon points=\" 103 10, 103 110, 17 60 \" />\n", ilc);
133 sprintf(line, " <%spolygon points=\" 106 14, 106 106, 14 60 \" />\n", ilc);
134 strcat(tmp, line);
135 sprintf(line, " </%ssymbol>\n", ilc); strcat(tmp, line);
136
137 sprintf(line, " <%ssymbol id=\"sym-ritr\" %s >\n", ilc, allsame);
138 strcat(tmp, line);
139// sprintf(line, " <%spolygon points=\" 17 10, 17 110, 103 60 \" />\n", ilc);
140 sprintf(line, " <%spolygon points=\" 14 14, 14 106, 106 60 \" />\n", ilc);
141 strcat(tmp, line);
142 sprintf(line, " </%ssymbol>\n", ilc); strcat(tmp, line);
143
144 sprintf(line, " <%ssymbol id=\"sym-diam\" %s >\n", ilc, allsame);
145 strcat(tmp, line);
146// sprintf(line, " <%spolygon points=\" 60 10, 110 60, 60 110, 10 60 \" />\n", ilc);
147 sprintf(line, " <%spolygon points=\" 60 14, 106 60, 60 106, 14 60 \" />\n", ilc);
148 strcat(tmp, line);
149 sprintf(line, " </%ssymbol>\n", ilc); strcat(tmp, line);
150
151 sprintf(line, " </%sdefs>\n", ilc); strcat(tmp, line);
152
153 return(svg_write(fp, tmp, errmsg, verbose-5));
154}
int svg_write(FILE *fp, const char *svg_string, char *errmsg, int verbose)
Definition svg_file.c:304
int SVG_INLINE
Definition svg_file.c:12

Referenced by svg_initiate(), svg_start_plot_viewport(), and svg_xhtml_initiate().

◆ svgColorName()

char * svgColorName ( const svgColor i)

Return pointer to string describing the color, or NULL if outside of limits.

See also
svgSymbolName
Parameters
iindex of color

Definition at line 38 of file svg_defs.c.

41 {
42 unsigned int n=0;
43 while(svgcolor[n]!=0) n++;
44 if(/*i<0 ||*/ i>n-1) return(NULL); //return(svgcolor[BLACK]);
45 else return(svgcolor[i]);
46}

Referenced by plot_fit_svg(), plot_fitrange_svg(), plot_svg(), and svg_create_legends().

◆ svgSymbolName()

char * svgSymbolName ( const svgSymbolType i)

Return pointer to string describing the symbol, or NULL if outside of limits.

See also
svgColorName, svg_define_symbols
Parameters
iindex of symbol

Definition at line 67 of file svg_defs.c.

70 {
71 unsigned int n=0;
72 while(svgsymbol[n]!=0) n++;
73 if(/*i<0 ||*/ i>n-1) return(NULL);
74 else return(svgsymbol[i]);
75}

Referenced by plot_fit_svg(), plot_fitrange_svg(), and plot_svg().

Variable Documentation

◆ SVG_INLINE