Back to index

texmacs  1.0.7.15
pdfdraw.h
Go to the documentation of this file.
00001 /*  $Header: /home/cvsroot/dvipdfmx/src/pdfdraw.h,v 1.14 2008/12/11 16:03:05 matthias Exp $
00002     
00003     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
00004 
00005     Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata,
00006     the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
00007     
00008     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
00009 
00010     This program is free software; you can redistribute it and/or modify
00011     it under the terms of the GNU General Public License as published by
00012     the Free Software Foundation; either version 2 of the License, or
00013     (at your option) any later version.
00014     
00015     This program is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018     GNU General Public License for more details.
00019     
00020     You should have received a copy of the GNU General Public License
00021     along with this program; if not, write to the Free Software
00022     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00023 */
00024 
00025 #ifndef _PDF_DRAW_H_
00026 #define _PDF_DRAW_H_
00027 
00028 #include "pdfcolor.h"
00029 #include "pdfdev.h"
00030 
00031 #define  PDF_DASH_SIZE_MAX  16
00032 #define  PDF_GSAVE_MAX      256
00033 
00034 extern void  pdf_dev_init_gstates  (void);
00035 extern void  pdf_dev_clear_gstates (void);
00036 
00037 #define pdf_copymatrix(m,n) do {\
00038   (m)->a = (n)->a; (m)->b = (n)->b;\
00039   (m)->c = (n)->c; (m)->d = (n)->d;\
00040   (m)->e = (n)->e; (m)->f = (n)->f;\
00041 } while (0)
00042 
00043 #define pdf_setmatrix(m,p,q,r,s,t,u) do {\
00044   (m)->a = (p); (m)->b = (q);\
00045   (m)->c = (r); (m)->d = (s);\
00046   (m)->e = (t); (m)->f = (u);\
00047 } while (0)
00048 
00049 /* m -> n x m */
00050 #define pdf_concatmatrix(m,n) do {\
00051   double _tmp_a, _tmp_b, _tmp_c, _tmp_d; \
00052   _tmp_a = (m)->a; _tmp_b = (m)->b; \
00053   _tmp_c = (m)->c; _tmp_d = (m)->d; \
00054   (m)->a  = ((n)->a) * _tmp_a + ((n)->b) * _tmp_c; \
00055   (m)->b  = ((n)->a) * _tmp_b + ((n)->b) * _tmp_d; \
00056   (m)->c  = ((n)->c) * _tmp_a + ((n)->d) * _tmp_c; \
00057   (m)->d  = ((n)->c) * _tmp_b + ((n)->d) * _tmp_d; \
00058   (m)->e += ((n)->e) * _tmp_a + ((n)->f) * _tmp_c; \
00059   (m)->f += ((n)->e) * _tmp_b + ((n)->f) * _tmp_d; \
00060 } while (0)
00061 
00062 typedef struct pdf_path_ pdf_path;
00063 
00064 extern int    pdf_dev_currentmatrix (pdf_tmatrix *M);
00065 extern int    pdf_dev_currentpoint  (pdf_coord *cp);
00066 
00067 extern int    pdf_dev_setlinewidth  (double  width);
00068 extern int    pdf_dev_setmiterlimit (double  mlimit);
00069 extern int    pdf_dev_setlinecap    (int     style);
00070 extern int    pdf_dev_setlinejoin   (int     style);
00071 extern int    pdf_dev_setdash       (int     count,
00072                                      double *pattern,
00073                                      double  offset);
00074 #if 0
00075 extern int    pdf_dev_setflat       (int     flatness);
00076 #endif
00077 
00078 /* Path Construction */
00079 extern int    pdf_dev_moveto        (double x , double y);
00080 extern int    pdf_dev_rmoveto       (double x , double y);
00081 extern int    pdf_dev_closepath     (void);
00082 
00083 extern int    pdf_dev_lineto        (double x0 , double y0);
00084 extern int    pdf_dev_rlineto       (double x0 , double y0);
00085 extern int    pdf_dev_curveto       (double x0 , double y0,
00086                                      double x1 , double y1,
00087                                      double x2 , double y2);
00088 extern int    pdf_dev_rcurveto      (double x0 , double y0,
00089                                      double x1 , double y1,
00090                                      double x2 , double y2);
00091 extern int    pdf_dev_arc           (double c_x, double c_y, double r,
00092                                      double a_0, double a_1);
00093 extern int    pdf_dev_arcn          (double c_x, double c_y, double r,
00094                                      double a_0, double a_1);
00095   
00096 #define PDF_FILL_RULE_NONZERO 0
00097 #define PDF_FILL_RULE_EVENODD 1
00098 
00099 extern int    pdf_dev_newpath       (void);
00100 
00101 /* Path Painting */
00102 extern int    pdf_dev_clip          (void);
00103 extern int    pdf_dev_eoclip        (void);
00104 
00105 
00106 #if 0
00107 extern int    pdf_dev_rectstroke    (double x, double y,
00108                                      double w, double h,
00109                                      const pdf_tmatrix *M  /* optional */
00110                                     );
00111 #endif
00112 extern int    pdf_dev_rectfill      (double x, double y, double w, double h);
00113 extern int    pdf_dev_rectclip      (double x, double y, double w, double h);
00114  
00115 extern int    pdf_dev_flushpath     (char p_op, int fill_rule);
00116 
00117 #define pdf_dev_fill()       pdf_dev_flushpath('f', PDF_FILL_RULE_NONZERO)
00118 #define pdf_dev_eofill()     pdf_dev_flushpath('f', PDF_FILL_RULE_EVENODD)
00119 #define pdf_dev_stroke()     pdf_dev_flushpath('S', PDF_FILL_RULE_NONZERO)
00120 #define pdf_dev_fillstroke() pdf_dev_flushpath('B', PDF_FILL_RULE_NONZERO)
00121 
00122 extern int    pdf_dev_concat        (const pdf_tmatrix *M);
00123 /* NULL pointer of M mean apply current transformation */
00124 extern void   pdf_dev_dtransform    (pdf_coord *p, const pdf_tmatrix *M);
00125 extern void   pdf_dev_idtransform   (pdf_coord *p, const pdf_tmatrix *M);
00126 extern void   pdf_dev_transform     (pdf_coord *p, const pdf_tmatrix *M);
00127 #if 0
00128 extern void   pdf_dev_itransform    (pdf_coord *p, const pdf_tmatrix *M);
00129 #endif
00130 
00131 extern int    pdf_dev_gsave         (void);
00132 extern int    pdf_dev_grestore      (void);
00133 
00134 /* Requires from mpost.c because new MetaPost graphics must initialize
00135  * the current gstate. */
00136 extern int    pdf_dev_push_gstate (void);
00137 extern int    pdf_dev_pop_gstate (void);
00138 
00139 
00140 /* extension */
00141 extern int    pdf_dev_arcx          (double c_x, double c_y,
00142                                      double r_x, double r_y,
00143                                      double a_0, double a_1,
00144                                      int    a_d, /* arc direction   */
00145                                      double xar  /* x-axis-rotation */
00146                                     );
00147 extern int    pdf_dev_bspline       (double x0, double y0,
00148                                      double x1, double y1,
00149                                      double x2, double y2);
00150 
00151  
00152 extern void   pdf_invertmatrix      (pdf_tmatrix *M);
00153   
00154 /* The depth here is the depth of q/Q nesting.
00155  * We must remember current depth of nesting when starting a page or xform,
00156  * and must recover until that depth at the end of page/xform.
00157  */
00158 extern int    pdf_dev_current_depth (void);
00159 extern void   pdf_dev_grestore_to   (int depth);
00160 #define pdf_dev_grestoreall() pdf_dev_grestore_to(0);
00161 
00162 extern void   pdf_dev_set_color     (const pdf_color *color, char mask, int force);
00163 #define pdf_dev_set_strokingcolor(c)     pdf_dev_set_color(c,    0, 0);
00164 #define pdf_dev_set_nonstrokingcolor(c)  pdf_dev_set_color(c, 0x20, 0);
00165 extern void   pdf_dev_reset_color   (int force);
00166 
00167 #endif /* _PDF_DRAW_H_ */