diff options
Diffstat (limited to 'Build/source/texk/dvipdfm-x/xsrc/spc_tpic.c')
-rw-r--r-- | Build/source/texk/dvipdfm-x/xsrc/spc_tpic.c | 153 |
1 files changed, 66 insertions, 87 deletions
diff --git a/Build/source/texk/dvipdfm-x/xsrc/spc_tpic.c b/Build/source/texk/dvipdfm-x/xsrc/spc_tpic.c index a63e61554f1..1e5f196e737 100644 --- a/Build/source/texk/dvipdfm-x/xsrc/spc_tpic.c +++ b/Build/source/texk/dvipdfm-x/xsrc/spc_tpic.c @@ -201,6 +201,60 @@ set_fillstyle (double g, double a, int f_ais) return 0; } +static void +set_styles (struct spc_tpic_ *tp, + const pdf_coord *c, + int f_fs, + int f_vp, + double pn, + double da) { + pdf_tmatrix M; + + pdf_setmatrix (&M, 1.0, 0.0, 0.0, -1.0, c->x, c->y); + pdf_dev_concat(&M); + + if (f_vp) + set_linestyle(pn, da); + + if (f_fs) { + double g, a; + int f_ais; + +#ifdef XETEX + switch (tp->mode.fill) { + case TPIC_MODE__FILL_SOLID: + g = 1.0 - tp->fill_color; + a = 0.0; + break; + case TPIC_MODE__FILL_SHAPE: + case TPIC_MODE__FILL_OPACITY: + if (tp->fill_color > 0.0) { + a = tp->fill_color; + g = 0.0; + } else { + a = 0.0; + g = 1.0; + } + break; + default: + g = 0.5; + a = 0.0; + } +#else + if (tp->mode.fill == TPIC_MODE__FILL_SOLID || !tp->fill_color) { + g = 1.0 - tp->fill_color; + a = 0.0; + } else { + g = 0.0; + a = tp->fill_color; + } +#endif + + f_ais = (tp->mode.fill == TPIC_MODE__FILL_SHAPE) ? 1 : 0; + + set_fillstyle(g, a, f_ais); + } +} static void showpath (int f_vp, int f_fs) /* visible_path, fill_shape */ @@ -235,45 +289,18 @@ tpic__polyline (struct spc_tpic_ *tp, int f_vp, double da) { - pdf_tmatrix M; double pn = tp->pen_size; int f_fs = tp->fill_shape; - int f_ais = 0; - double g = 0.5; - double a = 0.0; int i, error = 0; /* Shading is applied only to closed path. */ f_fs = CLOSED_PATH(tp) ? f_fs : 0; f_vp = (pn > 0.0) ? f_vp : 0; - f_ais = (tp->mode.fill == TPIC_MODE__FILL_SHAPE) ? 1 : 0; - switch (tp->mode.fill) { - case TPIC_MODE__FILL_SOLID: - g = 1.0 - tp->fill_color; - a = 0.0; - break; - case TPIC_MODE__FILL_SHAPE: - case TPIC_MODE__FILL_OPACITY: - if (tp->fill_color > 0.0) { - a = tp->fill_color; - g = 0.0; - } else { - a = 0.0; - g = 1.0; - } - break; - } if (f_vp || f_fs) { pdf_dev_gsave(); - pdf_setmatrix (&M, 1.0, 0.0, 0.0, -1.0, c->x, c->y); - pdf_dev_concat(&M); - - if (f_vp) - set_linestyle(pn, da); - if (f_fs) - set_fillstyle(g, a, f_ais); + set_styles(tp, c, f_fs, f_vp, pn, da); pdf_dev_moveto(tp->points[0].x, tp->points[0].y); for (i = 0; i < tp->num_points; i++) @@ -316,44 +343,17 @@ tpic__spline (struct spc_tpic_ *tp, double da) { double v[6]; - pdf_tmatrix M; double pn = tp->pen_size; int f_fs = tp->fill_shape; - int f_ais = 0; - double g = 0.5; - double a = 0.0; int i, error = 0; f_fs = CLOSED_PATH(tp) ? f_fs : 0; f_vp = (pn > 0.0) ? f_vp : 0; - f_ais = (tp->mode.fill == TPIC_MODE__FILL_SHAPE) ? 1 : 0; - switch (tp->mode.fill) { - case TPIC_MODE__FILL_SOLID: - g = 1.0 - tp->fill_color; - a = 0.0; - break; - case TPIC_MODE__FILL_SHAPE: - case TPIC_MODE__FILL_OPACITY: - if (tp->fill_color > 0.0) { - a = tp->fill_color; - g = 0.0; - } else { - a = 0.0; - g = 1.0; - } - break; - } - if ( f_vp || f_fs ) { + if (f_vp || f_fs) { pdf_dev_gsave(); - pdf_setmatrix (&M, 1.0, 0.0, 0.0, -1.0, c->x, c->y); - pdf_dev_concat(&M); - - if (f_vp) - set_linestyle(pn, da); - if (f_fs) - set_fillstyle(g, a, f_ais); + set_styles(tp, c, f_fs, f_vp, pn, da); pdf_dev_moveto(tp->points[0].x, tp->points[0].y); @@ -388,43 +388,16 @@ tpic__arc (struct spc_tpic_ *tp, double da, double *v /* 6 numbers */ ) { - pdf_tmatrix M; double pn = tp->pen_size; int f_fs = tp->fill_shape; - int f_ais = 0; - double g = 0.5; - double a = 0.0; f_fs = (round(fabs(v[4] - v[5]) + 0.5) >= 360) ? f_fs : 0; f_vp = (pn > 0.0) ? f_vp : 0; - f_ais = (tp->mode.fill == TPIC_MODE__FILL_SHAPE) ? 1 : 0; - switch (tp->mode.fill) { - case TPIC_MODE__FILL_SOLID: - g = 1.0 - tp->fill_color; - a = 0.0; - break; - case TPIC_MODE__FILL_SHAPE: - case TPIC_MODE__FILL_OPACITY: - if (tp->fill_color > 0.0) { - a = tp->fill_color; - g = 0.0; - } else { - a = 0.0; - g = 1.0; - } - break; - } - if ( f_vp || f_fs ) { + if (f_vp || f_fs) { pdf_dev_gsave(); - pdf_setmatrix (&M, 1.0, 0.0, 0.0, -1.0, c->x, c->y); - pdf_dev_concat(&M); - - if (f_vp) - set_linestyle(pn, da); - if (f_fs) - set_fillstyle(g, a, f_ais); + set_styles(tp, c, f_fs, f_vp, pn, da); pdf_dev_arcx(v[0], v[1], v[2], v[3], v[4], v[5], +1, 0.0); @@ -727,8 +700,14 @@ spc_handler_tpic_sh (struct spc_env *spe, skip_blank(&ap->curptr, ap->endptr); q = parse_float_decimal(&ap->curptr, ap->endptr); if (q) { - tp->fill_color = atof(q); + double g = atof(q); RELEASE(q); + if (g >= 0.0 && g <= 1.0) + tp->fill_color = g; + else { + WARN("Invalid fill color specified: %g\n", g); + return -1; + } } return 0; |