1 /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. 2 3 Copyright (C) 2002-2014 by Jin-Hwan Cho and Shunsaku Hirata, 4 the dvipdfmx project team. 5 6 Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> 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_vcurveto (double x0 , double y0, 87 double x1 , double y1); 88 extern int pdf_dev_ycurveto (double x0 , double y0, 89 double x1 , double y1); 90 extern int pdf_dev_rcurveto (double x0 , double y0, 91 double x1 , double y1, 92 double x2 , double y2); 93 extern int pdf_dev_arc (double c_x, double c_y, double r, 94 double a_0, double a_1); 95 extern int pdf_dev_arcn (double c_x, double c_y, double r, 96 double a_0, double a_1); 97 98 #define PDF_FILL_RULE_NONZERO 0 99 #define PDF_FILL_RULE_EVENODD 1 100 101 extern int pdf_dev_newpath (void); 102 103 /* Path Painting */ 104 extern int pdf_dev_clip (void); 105 extern int pdf_dev_eoclip (void); 106 107 #if 0 108 extern int pdf_dev_rectstroke (double x, double y, 109 double w, double h, 110 const pdf_tmatrix *M /* optional */ 111 ); 112 #endif 113 114 extern int pdf_dev_rectfill (double x, double y, double w, double h); 115 extern int pdf_dev_rectclip (double x, double y, double w, double h); 116 extern int pdf_dev_rectadd (double x, double y, double w, double h); 117 118 extern int pdf_dev_flushpath (char p_op, int fill_rule); 119 120 #define pdf_dev_fill() pdf_dev_flushpath('f', PDF_FILL_RULE_NONZERO) 121 #define pdf_dev_eofill() pdf_dev_flushpath('f', PDF_FILL_RULE_EVENODD) 122 #define pdf_dev_stroke() pdf_dev_flushpath('S', PDF_FILL_RULE_NONZERO) 123 #define pdf_dev_fillstroke() pdf_dev_flushpath('B', PDF_FILL_RULE_NONZERO) 124 125 extern int pdf_dev_concat (const pdf_tmatrix *M); 126 /* NULL pointer of M mean apply current transformation */ 127 extern void pdf_dev_dtransform (pdf_coord *p, const pdf_tmatrix *M); 128 extern void pdf_dev_idtransform (pdf_coord *p, const pdf_tmatrix *M); 129 extern void pdf_dev_transform (pdf_coord *p, const pdf_tmatrix *M); 130 #if 0 131 extern void pdf_dev_itransform (pdf_coord *p, const pdf_tmatrix *M); 132 #endif 133 134 extern int pdf_dev_gsave (void); 135 extern int pdf_dev_grestore (void); 136 137 /* Requires from mpost.c because new MetaPost graphics must initialize 138 * the current gstate. */ 139 extern int pdf_dev_push_gstate (void); 140 extern int pdf_dev_pop_gstate (void); 141 142 143 /* extension */ 144 extern int pdf_dev_arcx (double c_x, double c_y, 145 double r_x, double r_y, 146 double a_0, double a_1, 147 int a_d, /* arc direction */ 148 double xar /* x-axis-rotation */ 149 ); 150 extern int pdf_dev_bspline (double x0, double y0, 151 double x1, double y1, 152 double x2, double y2); 153 154 155 extern void pdf_invertmatrix (pdf_tmatrix *M); 156 157 /* The depth here is the depth of q/Q nesting. 158 * We must remember current depth of nesting when starting a page or xform, 159 * and must recover until that depth at the end of page/xform. 160 */ 161 extern int pdf_dev_current_depth (void); 162 extern void pdf_dev_grestore_to (int depth); 163 #define pdf_dev_grestoreall() pdf_dev_grestore_to(0); 164 165 #if 0 166 extern int pdf_dev_currentcolor (pdf_color *color, int is_fill); 167 #endif 168 169 extern void pdf_dev_set_fixed_point (double x, double y); 170 extern void pdf_dev_get_fixed_point (pdf_coord *p); 171 172 extern void pdf_dev_set_color (const pdf_color *color, char mask, int force); 173 #define pdf_dev_set_strokingcolor(c) pdf_dev_set_color(c, 0, 0); 174 #define pdf_dev_set_nonstrokingcolor(c) pdf_dev_set_color(c, 0x20, 0); 175 176 #endif /* _PDF_DRAW_H_ */ 177