40 "global_settings { assumed_gamma 1.0 }\n"
43 "#default { finish { ambient 0.1 diffuse 0.9 } }\n"
46 "#include \"colors.inc\"\n"\
47 "#include \"textures.inc\"\n"\
48 "#include \"shapes.inc\"\n"
51 "light_source { <1500,3000,-2500> color White }\n"
54 "camera { location <%.3f , %.3f , %.3f>\n"\
55 " look_at <%.3f , %.3f , %.3f>\n"\
56 " right x * image_width / image_height\n"\
60 #define POV_SKY_AND_GND \
62 "plane { <0, 1, 0>, 1 hollow\n"\
64 " pigment { bozo turbulence 0.95\n"\
66 " [0.00 rgb <0.05, 0.20, 0.50>]\n"\
67 " [0.50 rgb <0.05, 0.20, 0.50>]\n"\
68 " [0.75 rgb <1.00, 1.00, 1.00>]\n"\
69 " [0.75 rgb <0.25, 0.25, 0.25>]\n"\
70 " [1.00 rgb <0.50, 0.50, 0.50>]\n"\
72 " scale <1.00, 1.00, 1.50> * 2.50\n"\
73 " translate <0.00, 0.00, 0.00>\n"\
75 " finish { ambient 1 diffuse 0 }\n"\
82 " color rgb <1.00, 1.00, 1.00> * 0.75\n"\
88 "plane { <0.00, 1.00, 0.00>, 0\n"\
90 " pigment{ color rgb <0.25, 0.45, 0.00> }\n"\
91 " normal { bumps 0.75 scale 0.01 }\n"\
92 " finish { phong 0.10 }\n"\
97 "box { <%.3f, %.3f, %.3f>, <%.3f, %.3f, %.3f>\n"
103 "scale "POV_VECTOR3"\n"
106 "rotate "POV_VECTOR3"\n"
108 #define POV_TRANSLATE \
109 "translate"POV_VECTOR3"\n"
115 "torus { %.3f, %.3f\n"
117 #define POV_SPHERE_SWEEP \
123 "sphere {"POV_VECTOR3", 1.0\n" // center, radius
128 " \"%s\", %.3f, %.3f\n"
130 #define POV_DECLARE \
131 "#declare %s = %s;\n"
136 #define POV_VERBATIM \
142 #define POV_POLYGON \
145 #define POV_VECTOR3 \
146 "<%9.3f, %9.3f, %9.3f>"
148 #define POV_PIGMENT_COLOR \
149 "pigment { color %s }\n"
151 #define POV_COLOR_NAME \
154 #define POV_COLOR_RGB \
155 "rgb"POV_VECTOR3" transmit %.3f"
231 "mediumforestgreen",\
236 "mediumspringgreen",\
275 "very_light_purple",\
283 #define GV_OBJ_EXT(type, obj, name) \
285 char debug_str[256]; \
286 gvprintf(job, POV_DECLARE, type, obj); \
287 gvprintf(job, POV_OBJECT, type); \
288 gvprintf(job, POV_DECLARE, "Min", "min_extent("type")"); \
289 gvprintf(job, POV_DECLARE, "Max", "max_extent("type")"); \
290 snprintf(debug_str, 256, \
291 "concat(\"Dim = \" , vstr(3, Max - Min, \", \", 0, 3)," \
292 " \" "type": %s\", \"\\n\")", name); \
293 gvprintf(job, POV_DEBUG, debug_str); \
341 #define RENDERER_COLOR_TYPE RGBA_BYTE
359 static char *pov_knowncolors[] = {
POV_COLORS };
361 static float layerz = 0;
366 #if defined(HAVE_VASPRINTF)
370 va_start(arglist,
template);
371 vasprintf(&str,
template, arglist);
375 #elif defined(HAVE_VSNPRINTF)
381 va_start(arglist,
template);
382 len = vsnprintf((
char *)buf, BUFSIZ,
template, arglist);
384 job->
common->
errorfn(
"pov renderer:el - %s\n", strerror(errno));
387 else if (len >= BUFSIZ) {
388 str = malloc (len+1);
390 va_start(arglist,
template);
391 len = vsprintf(str,
template, arglist);
405 static char *pov_color_as_str(
GVJ_t * job,
gvcolor_t color,
float transparency)
407 char *pov, *c =
NULL;
408 switch (color.
type) {
413 if (!strcmp(color.
u.
string,
"red"))
415 else if (!strcmp(color.
u.
string,
"green"))
417 else if (!strcmp(color.
u.
string,
"blue"))
424 gvprintf(job,
"// type = %d, color = %d, %d, %d\n",
429 color.
u.
rgba[0] / 256.0, color.
u.
rgba[1] / 256.0,
430 color.
u.
rgba[2] / 256.0, transparency);
434 "oops, internal error: unhandled color type=%d %s\n",
443 static void pov_comment(
GVJ_t * job,
char *
str)
445 gvprintf(job,
"//*** comment: %s\n", str);
448 static void pov_begin_job(
GVJ_t * job)
458 static void pov_begin_graph(
GVJ_t * job)
460 float x, y, d, px, py;
464 gvprintf(job,
"// graph_index = %d, pages = %d, layer = %d/%d\n",
469 gvprintf(job,
"// pagesArrayFirst.x,y = %d,%d\n",
473 gvprintf(job,
"// bb.LL,UR = %.3f,%.3f, %.3f,%.3f\n", job->
bb.
LL.
x,
475 gvprintf(job,
"// pageBox in graph LL,UR = %.3f,%.3f, %.3f,%.3f\n",
481 gvprintf(job,
"// zoom = %.3f, rotation = %d\n", job->
zoom,
485 gvprintf(job,
"// canvasBox LL,UR = %.3f,%.3f, %.3f,%.3f\n",
488 gvprintf(job,
"// pageBoundingBox LL,UR = %d,%d, %d,%d\n",
491 gvprintf(job,
"// boundingBox (all pages) LL,UR = %d,%d, %d,%d\n",
509 px = atanf(x / fabsf(d)) * 180 /
M_PI * 2;
510 py = atanf(y / fabsf(d)) * 180 /
M_PI * 2;
512 (px > py ? px : py) * 1.2);
517 static void pov_end_graph(
GVJ_t * job)
519 gvputs(job,
"//*** end_graph\n");
522 static void pov_begin_layer(
GVJ_t * job,
char *layername,
int layerNum,
int numLayers)
524 gvprintf(job,
"//*** begin_layer: %s, %d/%d\n", layername, layerNum,
526 layerz = layerNum * -10;
529 static void pov_end_layer(
GVJ_t * job)
531 gvputs(job,
"//*** end_layer\n");
534 static void pov_begin_page(
GVJ_t * job)
536 gvputs(job,
"//*** begin_page\n");
539 static void pov_end_page(
GVJ_t * job)
541 gvputs(job,
"//*** end_page\n");
544 static void pov_begin_cluster(
GVJ_t * job)
546 gvputs(job,
"//*** begin_cluster\n");
550 static void pov_end_cluster(
GVJ_t * job)
552 gvputs(job,
"//*** end_cluster\n");
555 static void pov_begin_node(
GVJ_t * job)
560 static void pov_end_node(
GVJ_t * job)
562 gvputs(job,
"//*** end_node\n");
565 static void pov_begin_edge(
GVJ_t * job)
567 gvputs(job,
"//*** begin_edge\n");
570 gvprintf(job,
"// layerz = %.3f\n", layerz);
574 static void pov_end_edge(
GVJ_t * job)
576 gvputs(job,
"//*** end_edge\n");
579 gvprintf(job,
"// layerz = %.3f\n", layerz);
586 char *pov, *
s, *r, *t, *p;
588 gvprintf(job,
"//*** textspan: %s, fontsize = %.3f, fontname = %s\n",
594 gvputs(job,
"// Warning: postscript_alias not handled!\n");
598 switch (span->
just) {
606 c.
x = c.
x - span->
size.
x / 2.0;
616 p = pov_color_as_str(job, job->
obj->
pencolor, 0.0);
621 span->
str,
" no_shadow\n", s, r, t, p);
625 gvprintf(job,
"sphere{<0, 0, 0>, 2\ntranslate<%f, %f, %f>\n"
626 "pigment{color Red}\nno_shadow\n}\n", x, y, z - 1);
638 static void pov_ellipse(
GVJ_t * job,
pointf * A,
int filled)
640 char *pov, *s, *r, *t, *p;
641 float cx, cy, rx, ry, w;
643 gvputs(job,
"//*** ellipse\n");
649 rx = (A[1].
x - A[0].
x) * job->
scale.
x;
650 ry = (A[1].
y - A[0].
y) * job->
scale.
y;
657 p = pov_color_as_str(job, job->
obj->
pencolor, 0.0);
664 gvprintf(job,
"sphere{<0, 0, 0>, 2\ntranslate<%f, %f, %f>\n"
665 "pigment{color Green}\nno_shadow\n}\n", cx, cy, z - 1);
684 0.0, 0.0, 0.0, s, r, t, p);
696 static void pov_bezier(
GVJ_t * job,
pointf * A,
int n,
int arrow_at_start,
697 int arrow_at_end,
int filled)
701 char *pov, *s, *r, *t, *p;
703 gvputs(job,
"//*** bezier\n");
713 for (i = 0; i < n; i++) {
715 x =
el(job,
"%s %s", pov, v);
722 if (i == 0 || i == n - 1) {
724 x =
el(job,
"%s %s", pov, v);
730 gvprintf(job,
"sphere{<0, 0, 0>, 2\ntranslate<%f, %f, %f>\n"
731 "pigment{color Yellow}\nno_shadow\n}\n",
736 x =
el(job,
" tolerance 0.01\n %s %s %s %s" END, s, r, t,
738 pov =
el(job,
"%s%s", pov, x);
750 static void pov_polygon(
GVJ_t * job,
pointf * A,
int n,
int filled)
752 char *pov, *s, *r, *t, *p, *v, *x;
755 gvputs(job,
"//*** polygon\n");
761 p = pov_color_as_str(job, job->
obj->
pencolor, 0.0);
765 for (i = 0; i < n; i++) {
767 x =
el(job,
"%s %s", pov, v);
776 x =
el(job,
"%s %s", pov, v);
781 x =
el(job,
" tolerance 0.1\n %s %s %s %s" END, s, r, t, p);
782 pov =
el(job,
"%s%s", pov, x);
802 for (i = 0; i < n; i++) {
807 x =
el(job,
"%s\n %s", pov, v);
812 x =
el(job,
"\n %s %s %s %s" END, s, r, t, p);
813 pov =
el(job,
"%s%s", pov, x);
826 static void pov_polyline(
GVJ_t * job,
pointf * A,
int n)
828 char *pov, *s, *r, *t, *p, *v, *x;
831 gvputs(job,
"//*** polyline\n");
837 p = pov_color_as_str(job, job->
obj->
pencolor, 0.0);
841 for (i = 0; i < n; i++) {
843 x =
el(job,
"%s %s", pov, v);
849 x =
el(job,
" tolerance 0.01\n %s %s %s %s" END, s, r, t, p);
850 pov =
el(job,
"%s%s", pov, x);
908 sizeof(pov_knowncolors) /
sizeof(
char *),
920 #ifdef HAVE_VSNPRINTF
927 #ifdef HAVE_VSNPRINTF
#define GVRENDER_DOES_MAP_ELLIPSE
#define GVRENDER_DOES_MAP_POLYGON
gvrender_features_t render_features_pov
#define RENDERER_COLOR_TYPE
gvplugin_installed_t gvdevice_pov_types[]
#define GVRENDER_DOES_MAP_RECTANGLE
#define GVRENDER_DOES_TRANSFORM
gvplugin_installed_t gvrender_pov_types[]
int gvputs(GVJ_t *job, const char *s)
#define GV_OBJ_EXT(type, obj, name)
#define GVRENDER_DOES_MAP_CIRCLE
#define GVDEVICE_DOES_LAYERS
CGRAPH_API char * agnameof(void *)
PostscriptAlias * postscript_alias
void(* errorfn)(const char *fmt,...)
#define GVRENDER_NO_WHITE_BG
#define POV_PIGMENT_COLOR
gvdevice_features_t device_features_pov
gvrender_engine_t pov_engine
char * el(GVJ_t *job, char *template,...)
#define GVDEVICE_DOES_TRUECOLOR
void gvprintf(GVJ_t *job, const char *format,...)
#define GVRENDER_DOES_MAP_BSPLINE