| 1 |
/* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. |
| 2 |
|
| 3 |
Copyright (C) 2002-2020 by Jin-Hwan Cho and Shunsaku Hirata, |
| 4 |
the dvipdfmx project team. |
| 5 |
|
| 6 |
Copyright (C) 1998, 1999 by Mark A. Wicks <[email protected]> |
| 7 |
|
| 8 |
This program is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; either version 2 of the License, or |
| 11 |
(at your option) any later version. |
| 12 |
|
| 13 |
This program is distributed in the hope that it will be useful, |
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
GNU General Public License for more details. |
| 17 |
|
| 18 |
You should have received a copy of the GNU General Public License |
| 19 |
along with this program; if not, write to the Free Software |
| 20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
| 21 |
*/ |
| 22 |
|
| 23 |
#ifndef _PDF_DRAW_H_ |
| 24 |
#define _PDF_DRAW_H_ |
| 25 |
|
| 26 |
#include "pdfcolor.h" |
| 27 |
#include "pdfdev.h" |
| 28 |
|
| 29 |
#define PDF_DASH_SIZE_MAX 16 |
| 30 |
#define PDF_GSAVE_MAX 256 |
| 31 |
|
| 32 |
extern void pdf_dev_init_gstates (void); |
| 33 |
extern void pdf_dev_clear_gstates (void); |
| 34 |
|
| 35 |
#define pdf_copymatrix(m,n) do {\ |
| 36 |
(m)->a = (n)->a; (m)->b = (n)->b;\ |
| 37 |
(m)->c = (n)->c; (m)->d = (n)->d;\ |
| 38 |
(m)->e = (n)->e; (m)->f = (n)->f;\ |
| 39 |
} while (0) |
| 40 |
|
| 41 |
#define pdf_setmatrix(m,p,q,r,s,t,u) do {\ |
| 42 |
(m)->a = (p); (m)->b = (q);\ |
| 43 |
(m)->c = (r); (m)->d = (s);\ |
| 44 |
(m)->e = (t); (m)->f = (u);\ |
| 45 |
} while (0) |
| 46 |
|
| 47 |
/* m -> n x m */ |
| 48 |
#define pdf_concatmatrix(m,n) do {\ |
| 49 |
double _tmp_a, _tmp_b, _tmp_c, _tmp_d; \ |
| 50 |
_tmp_a = (m)->a; _tmp_b = (m)->b; \ |
| 51 |
_tmp_c = (m)->c; _tmp_d = (m)->d; \ |
| 52 |
(m)->a = ((n)->a) * _tmp_a + ((n)->b) * _tmp_c; \ |
| 53 |
(m)->b = ((n)->a) * _tmp_b + ((n)->b) * _tmp_d; \ |
| 54 |
(m)->c = ((n)->c) * _tmp_a + ((n)->d) * _tmp_c; \ |
| 55 |
(m)->d = ((n)->c) * _tmp_b + ((n)->d) * _tmp_d; \ |
| 56 |
(m)->e += ((n)->e) * _tmp_a + ((n)->f) * _tmp_c; \ |
| 57 |
(m)->f += ((n)->e) * _tmp_b + ((n)->f) * _tmp_d; \ |
| 58 |
} while (0) |
| 59 |
|
| 60 |
typedef struct pdf_path_ pdf_path; |
| 61 |
|
| 62 |
extern int pdf_dev_currentmatrix (pdf_tmatrix *M); |
| 63 |
extern int pdf_dev_currentpoint (pdf_coord *cp); |
| 64 |
|
| 65 |
extern int pdf_dev_setlinewidth (double width); |
| 66 |
extern int pdf_dev_setmiterlimit (double mlimit); |
| 67 |
extern int pdf_dev_setlinecap (int style); |
| 68 |
extern int pdf_dev_setlinejoin (int style); |
| 69 |
extern int pdf_dev_setdash (int count, |
| 70 |
double *pattern, |
| 71 |
double offset); |
| 72 |
#if 0 |
| 73 |
extern int pdf_dev_setflat (int flatness); |
| 74 |
#endif |
| 75 |
|
| 76 |
/* Path Construction */ |
| 77 |
extern int pdf_dev_moveto (double x , double y); |
| 78 |
extern int pdf_dev_rmoveto (double x , double y); |
| 79 |
extern int pdf_dev_closepath (void); |
| 80 |
|
| 81 |
extern int pdf_dev_lineto (double x0 , double y0); |
| 82 |
extern int pdf_dev_rlineto (double x0 , double y0); |
| 83 |
extern int pdf_dev_curveto (double x0 , double y0, |
| 84 |
double x1 , double y1, |
| 85 |
double x2 , double y2); |
| 86 |
extern int pdf_dev_rcurveto (double x0 , double y0, |
| 87 |
double x1 , double y1, |
| 88 |
double x2 , double y2); |
| 89 |
extern int pdf_dev_arc (double c_x, double c_y, double r, |
| 90 |
double a_0, double a_1); |
| 91 |
extern int pdf_dev_arcn (double c_x, double c_y, double r, |
| 92 |
double a_0, double a_1); |
| 93 |
|
| 94 |
#define PDF_FILL_RULE_NONZERO 0 |
| 95 |
#define PDF_FILL_RULE_EVENODD 1 |
| 96 |
|
| 97 |
extern int pdf_dev_newpath (void); |
| 98 |
|
| 99 |
/* Path Painting */ |
| 100 |
extern int pdf_dev_clip (void); |
| 101 |
extern int pdf_dev_eoclip (void); |
| 102 |
|
| 103 |
|
| 104 |
extern int pdf_dev_rectstroke (double x, double y, |
| 105 |
double w, double h, |
| 106 |
const pdf_tmatrix *M /* optional */ |
| 107 |
); |
| 108 |
extern int pdf_dev_rectfill (double x, double y, double w, double h); |
| 109 |
extern int pdf_dev_rectclip (double x, double y, double w, double h); |
| 110 |
|
| 111 |
extern int pdf_dev_flushpath (char p_op, int fill_rule); |
| 112 |
|
| 113 |
extern int pdf_dev_concat (const pdf_tmatrix *M); |
| 114 |
/* NULL pointer of M mean apply current transformation */ |
| 115 |
extern void pdf_dev_dtransform (pdf_coord *p, const pdf_tmatrix *M); |
| 116 |
extern void pdf_dev_idtransform (pdf_coord *p, const pdf_tmatrix *M); |
| 117 |
extern void pdf_dev_transform (pdf_coord *p, const pdf_tmatrix *M); |
| 118 |
extern void pdf_dev_itransform (pdf_coord *p, const pdf_tmatrix *M); |
| 119 |
|
| 120 |
extern int pdf_dev_gsave (void); |
| 121 |
extern int pdf_dev_grestore (void); |
| 122 |
|
| 123 |
/* Requires from mpost.c because new MetaPost graphics must initialize |
| 124 |
* the current gstate. */ |
| 125 |
extern int pdf_dev_push_gstate (void); |
| 126 |
extern int pdf_dev_pop_gstate (void); |
| 127 |
|
| 128 |
|
| 129 |
/* extension */ |
| 130 |
extern int pdf_dev_arcx (double c_x, double c_y, |
| 131 |
double r_x, double r_y, |
| 132 |
double a_0, double a_1, |
| 133 |
int a_d, /* arc direction */ |
| 134 |
double xar /* x-axis-rotation */ |
| 135 |
); |
| 136 |
extern int pdf_dev_bspline (double x0, double y0, |
| 137 |
double x1, double y1, |
| 138 |
double x2, double y2); |
| 139 |
|
| 140 |
|
| 141 |
extern void pdf_invertmatrix (pdf_tmatrix *M); |
| 142 |
|
| 143 |
/* The depth here is the depth of q/Q nesting. |
| 144 |
* We must remember current depth of nesting when starting a page or xform, |
| 145 |
* and must recover until that depth at the end of page/xform. |
| 146 |
*/ |
| 147 |
extern int pdf_dev_current_depth (void); |
| 148 |
extern void pdf_dev_grestore_to (int depth); |
| 149 |
|
| 150 |
#if 0 |
| 151 |
extern int pdf_dev_currentcolor (pdf_color *color, int is_fill); |
| 152 |
#endif |
| 153 |
|
| 154 |
extern void pdf_dev_set_fixed_point (double x, double y); |
| 155 |
extern void pdf_dev_get_fixed_point (pdf_coord *p); |
| 156 |
|
| 157 |
extern void pdf_dev_set_color (const pdf_color *color, char mask, int force); |
| 158 |
#define pdf_dev_set_strokingcolor(c) pdf_dev_set_color(c, 0, 0); |
| 159 |
#define pdf_dev_set_nonstrokingcolor(c) pdf_dev_set_color(c, 0x20, 0); |
| 160 |
|
| 161 |
extern void pdf_dev_xgstate_push (pdf_obj *object); |
| 162 |
extern void pdf_dev_xgstate_pop (void); |
| 163 |
extern int pdf_dev_reset_xgstate (int force); |
| 164 |
|
| 165 |
#endif /* _PDF_DRAW_H_ */ |