/* Copyright (C) 2018-2020, Dirk Krause SPDX-License-Identifier: BSD-3-Clause */ /* WARNING: This file was generated by the dkct program (see http://dktools.sourceforge.net/ for details). Changes you make here will be lost if dkct is run again! You should modify the original source and run dkct on it. Original source: dk4graa.ctr */ #ifndef DK4GRAA_H_INCLUDED /** Avoid multiple inclusions. */ #define DK4GRAA_H_INCLUDED 1 #line 9 "dk4graa.ctr" /** @file dk4graa.h Graphics output (PS/EPS/PDF/PGF), application support. */ #ifndef DK4CONF_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4conf.h" #else #include #endif #endif #ifndef DK4GRA_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4gra.h" #else #include #endif #endif #ifndef DK4APP_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4app.h" #else #include #endif #endif #ifdef __cplusplus extern "C" { #endif /** Open output structure to create a PDF file. @param fn File name for output file, NULL for standard output. @param w Image width in bp. @param h Image height in bp. @param docfl Document flag set. @param app Application structure for diagnostics, may be NULL. @return Valid pointer to new structure on success, NULL on error. */ dk4_gra_t * dk4gra_app_open_pdf( const dkChar *fn, size_t w, size_t h, int docfl, dk4_app_t *app ); /** Open output structure to create a PS or EPS file. @param fn File name for output file, NULL for standard output. @param w Image width in bp. @param h Image height in bp. @param docfl Flag set, or combination of: - DK4_GRA_DOC_FLAG_PS2
to produce PS level 2 instead of level 3, - DK4_GRA_DOC_FLAG_EPS
to produce EPS instead of PS, - DK4_GRA_DOC_FLAG_PS_DSC
to write document structuring comments. @param app Application structure for diagnostics, may be NULL. @return Valid pointer to new structure on success, NULL on error. */ dk4_gra_t * dk4gra_app_open_ps( const dkChar *fn, size_t w, size_t h, int docfl, dk4_app_t *app ); /** Open output structure to create a PGF file. @param fn File name for output file, NULL for standard output. @param w Image width in bp. @param h Image height in bp. @param docfl Document flag set. @param sa Flag: Produce standalone TeX file. @param app Application structure for diagnostics, may be NULL. @return Valid pointer to new structure on success, NULL on error. */ dk4_gra_t * dk4gra_app_open_pgf( const dkChar *fn, size_t w, size_t h, int docfl, int sa, dk4_app_t *app ); /** Write output file and close output structure. @param gra Output structure. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_write_and_close( dk4_gra_t *gra, int *backptr, dk4_app_t *app ); /** Write output file and close output structure. @param fout Output file already opened. @param gra Output structure. @param app Application structure for diagnostics, may be NULL. @param backptr Address of success variable to reset on errors. */ void dk4gra_app_write_file_and_close( FILE *fout, dk4_gra_t *gra, int *backptr, dk4_app_t *app ); /** Set color space conversion context. @param gra Output structure. @param ctx Color space conversion context to copy. @param backptr Application structure for diagnostics, may be NULL. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_set_color_conversion( dk4_gra_t *gra, dk4_cs_conv_ctx_t const *ctx, int *backptr, dk4_app_t *app ); /** Start new page. Default flags are used for the page: - The clip path is set to the image dimensions. - Background is filled white. - For PDF the contents stream is compressed. To start a new page with different setup, use dk4gra_page_with_flags() instead and specify flags. @param gra Output structure. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_page( dk4_gra_t *gra, int *backptr, dk4_app_t *app ); /** Start new page with non-default setup. @param gra Output structure. @param flags Or-combined flags: - DK4_GRA_PAGE_FLAG_NO_CLIP
to avoid setting the clip path at start of page, - DK4_GRA_PAGE_FLAG_NO_BG
to avoid white background filling, - DK4_GRA_PAGE_FLAG_NOT_COMPRESSED
to avoid compression of page content stream in PDF. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_page_with_flags( dk4_gra_t *gra, int flags, int *backptr, dk4_app_t *app ); /** Set flag for simplified gsave/grestore handling. Set this flag, if you use gsave and grestore only when dealing with clip path for pattern filling. @param gra Output structure. @param val New flag value. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_set_gs_for_pattern_only( dk4_gra_t *gra, int val, dk4_app_t *app ); /** Save current graphics state (especially clip path). @param gra Output structure. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_gsave( dk4_gra_t *gra, int *backptr, dk4_app_t *app ); /** Restore graphics state (especially clip path). @param gra Output structure. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_grestore( dk4_gra_t *gra, int *backptr, dk4_app_t *app ); /** Set line width. @param gra Output structure. @param lw Line width in bp. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_set_line_width( dk4_gra_t *gra, double lw, int *backptr, dk4_app_t *app ); /** Set line style. @param gra Output structure. @param ls Line style. @param sv Style value (dash length in bp). @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_set_line_style( dk4_gra_t *gra, dk4_gra_ls_t ls, double sv, int *backptr, dk4_app_t *app ); /** Set line cap. @param gra Output structure. @param lc Line cap type. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_set_line_cap( dk4_gra_t *gra, dk4_gra_lc_t lc, int *backptr, dk4_app_t *app ); /** Set line join. @param gra Output structure. @param lj Line join type. @param ml Miter limit, only used if lj is DK4_GRA_LJ_MITERED. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_set_line_join( dk4_gra_t *gra, dk4_gra_lj_t lj, double ml, int *backptr, dk4_app_t *app ); /** Set fill color to gray. @param gra Output structure. @param g Gray value in interval 0 to 1. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_set_fill_gray( dk4_gra_t *gra, double g, int *backptr, dk4_app_t *app ); /** Set fill color to RGB. @param gra Output structure. @param r Red value in interval 0 to 1. @param g Green value in interval 0 to 1. @param b Blue value in interval 0 to 1. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_set_fill_rgb( dk4_gra_t *gra, double r, double g, double b, int *backptr, dk4_app_t *app ); /** Set fill color to CMYK. @param gra Output structure. @param c Cyan value in interval 0 to 1. @param m Magenta value in interval 0 to 1. @param y Yellow value in interval 0 to 1. @param k Black value in interval 0 to 1. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_set_fill_cmyk( dk4_gra_t *gra, double c, double m, double y, double k, int *backptr, dk4_app_t *app ); /** Set stroke color to gray. @param gra Output structure. @param g Gray value in interval 0 to 1. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_set_stroke_gray( dk4_gra_t *gra, double g, int *backptr, dk4_app_t *app ); /** Set stroke color to RGB. @param gra Output structure. @param r Red value in interval 0 to 1. @param g Green value in interval 0 to 1. @param b Blue value in interval 0 to 1. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_set_stroke_rgb( dk4_gra_t *gra, double r, double g, double b, int *backptr, dk4_app_t *app ); /** Set stroke color to CMYK. @param gra Output structure. @param c Cyan value in interval 0 to 1. @param m Magenta value in interval 0 to 1. @param y Yellow value in interval 0 to 1. @param k Black value in interval 0 to 1. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_set_stroke_cmyk( dk4_gra_t *gra, double c, double m, double y, double k, int *backptr, dk4_app_t *app ); /** Prepare output structure for a fill operation. Use this function before you start to construct a path you plan to fill. @param gra Output structure. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_prepare_fill( dk4_gra_t *gra, int *backptr, dk4_app_t *app ); /** Prepare output structure for a stroke operation. Use this function before you start to construct a path you plan to stroke. @param gra Output structure. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_prepare_stroke( dk4_gra_t *gra, int *backptr, dk4_app_t *app ); /** Prepare output structure for a combined fill and stroke operation. Use this function before you start to construct a path you plan to fill and stroke. @param gra Output structure. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_prepare_fill_and_stroke( dk4_gra_t *gra, int *backptr, dk4_app_t *app ); /** Fill current path. Note: Use dk4gra_prepare_fill() before you start to construct a path you plan to fill. The value of the even-odd-rule flag is used to choose either even-odd-rule or nonzero-winding-rule, the dk4gra_set_eorule() function can be used to set the flag. @param gra Output structure. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_fill( dk4_gra_t *gra, int *backptr, dk4_app_t *app ); /** Stroke current path. Note: Use dk4gra_app_prepare_stroke() before you start to construct a path you plan to stroke. @param gra Output structure. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_stroke( dk4_gra_t *gra, int *backptr, dk4_app_t *app ); /** Fill and stroke current path. Note: Use dk4gra_app_prepare_fill_and_stroke() before you start to construct a path you plan to fill and stroke. The value of the even-odd-rule flag is used to choose either even-odd-rule or nonzero-winding-rule, the dk4gra_app_set_eorule() function can be used to set the flag. @param gra Output structure. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_fill_and_stroke( dk4_gra_t *gra, int *backptr, dk4_app_t *app ); /** Use current path for clipping. The value of the even-odd-rule flag is used to choose either even-odd-rule or nonzero-winding-rule, the dk4gra_app_set_eorule() function can be used to set the flag. @param gra Output structure. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_clip( dk4_gra_t *gra, int *backptr, dk4_app_t *app ); /** Pattern a region (clipping should be set to the path). @param gra Output structure. @param xl Left y coordinate. @param xr Right x coordinate. @param yb Bottom y coordinate. @param yt Top y coordinate. @param pn Pattern number. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_pattern( dk4_gra_t *gra, double xl, double xr, double yb, double yt, dk4_gra_pattern_t pn, int *backptr, dk4_app_t *app ); /** Start a new path and move to first point. @param gra Output structure. @param x X coordinate of start point. @param y Y coordinate of start point. @param bbptr Bounding box, may be NULL. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_newpath_moveto( dk4_gra_t *gra, double x, double y, dk4_bb_t *bbptr, int *backptr, dk4_app_t *app ); /** Add line from current point to new point to path. @param gra Output structure. @param x X coordinate of new point. @param y Y coordinate of new point. @param bbptr Bounding box, may be NULL. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_lineto( dk4_gra_t *gra, double x, double y, dk4_bb_t *bbptr, int *backptr, dk4_app_t *app ); /** Add Bezier curve segment from current point to new point in path. @param gra Output structure. @param xc1 X coordinate of first control point. @param yc1 Y coordinate of first control point. @param xc2 X coordinate of second control point. @param yc2 Y coordinate of second control point. @param x X coordinate of new point. @param y Y coordinate of new point. @param bbptr Bounding box, may be NULL. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_curveto( dk4_gra_t *gra, double xc1, double yc1, double xc2, double yc2, double x, double y, dk4_bb_t *bbptr, int *backptr, dk4_app_t *app ); /** Close current path. @param gra Output structure. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_closepath( dk4_gra_t *gra, int *backptr, dk4_app_t *app ); /** Create path for a circle. @param gra Output structure. @param xc Center point x coordinate. @param yc Center point y coordinate. @param r Radius. @param bbptr Bounding box, may be NULL. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_circle( dk4_gra_t *gra, double xc, double yc, double r, dk4_bb_t *bbptr, int *backptr, dk4_app_t *app ); /** Create path for rectangle parallel to axes, optionally with rounded corners. @param gra Output structure. @param xl Left x coordinate. @param xr Right x coordinate. @param yb Bottom y coordinate. @param yt Top y coordinate. @param r Corner radius, maximum is a half of the smaller side length. Use negative values to avoid rounded corners. @param bbptr Bounding box, may be NULL. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_rectangle( dk4_gra_t *gra, double xl, double xr, double yb, double yt, double r, dk4_bb_t *bbptr, int *backptr, dk4_app_t *app ); /** Add path for an arc. @param gra Output structure. @param xc Center point x coordinate. @param yc Center point y coordinate. @param ra Radius. @param start Start angle in degree. @param end End angle in degree. @param cl Flag: Draw closed arc (piece of cake) instead of simple arc. @param bbptr Bounding box, may be NULL. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_arc( dk4_gra_t *gra, double xc, double yc, double ra, double start, double end, int cl, dk4_bb_t *bbptr, int *backptr, dk4_app_t *app ); /** Create path for an ellipse. @param gra Output structure. @param xc Center point x coordinate. @param yc Center point y coordinate. @param rx Radius in x direction. @param ry Radius in y direction. @param rot Rotation counterclockwise in degree. @param bbptr Bounding box, may be NULL. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_ellipse( dk4_gra_t *gra, double xc, double yc, double rx, double ry, double rot, dk4_bb_t *bbptr, int *backptr, dk4_app_t *app ); /** Add simple (non-special) text to PGF graphics. The text is shown in the current fill color (non-stroking color) unless colspec is used to specify a color. @param gra Output structure, must be initialized for PGF. @param x X coordinate. @param y Y coordinate. @param rot Rotation counterclockwise in degree. @param txt Text to show. @param colspec Color specification, may be NULL to use fill color. @param ie Text encoding, only used for char text. @param ha Horizontal alignment. @param va Vertical alignment. @param fno Font number. @param fsz Font size in pt. @param fex Flag: Use exact font (1) or similar font (0). @param uc2l UC to LaTeX conversion structure. @param flags Text flags DK4_GRA_TEXT_FLAG_xxx, can be or-combined. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_pgf_simple_text( dk4_gra_t *gra, double x, double y, double rot, const dkChar *txt, const char *colspec, int ie, dk4_text_align_h_t ha, dk4_text_align_v_t va, int fno, double fsz, dk4_gra_tf_t fex, dk4_uc2l_t *uc2l, int flags, int *backptr, dk4_app_t *app ); /** Add special text to PGF graphics. The text is shown in the current fill color (non-stroking color) unless colspec is used to specify a color. @param gra Output structure, must be initialized for PGF. @param x X coordinate. @param y Y coordinate. @param rot Rotation counterclockwise in degree. @param txt Text to show. @param colspec Color specification, may be NULL. @param ha Horizontal alignment. @param va Vertical alignment. @param fno Font number. @param fsz Font size in pt. @param fex Flag: Use exact font. @param flags Text flags DK4_GRA_TEXT_FLAG_xxx, can be or-combined. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_pgf_special_text( dk4_gra_t *gra, double x, double y, double rot, const char *txt, const char *colspec, dk4_text_align_h_t ha, dk4_text_align_v_t va, int fno, double fsz, dk4_gra_tf_t fex, int flags, int *backptr, dk4_app_t *app ); /** Add bitmap image with coordinate transformations already calculated. @param gra Output structure. @param cotra Array containing coordinate transformations. @param bif Bitmap image file. @param fn Image file name. @param fno Frame number. The frame number given here is used by the PDF output driver only. You must call dk4bif_set_current_frame() on the bitmap image file before calling this function. @param ifl Image flags. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_bif_cotra_image( dk4_gra_t *gra, double *cotra, dk4_bif_t *bif, const dkChar *fn, size_t fno, int ifl, int *backptr, dk4_app_t *app ); /** Add bitmap image XFig style. @param gra Output structure. @param xl Left x coordinate. @param xr Right x coordinate. @param yb Bottom y coordinate. @param yt Top y coordinate. @param bif Bitmap image file. @param fn Image file name. @param fno Frame number (0 for first frame). @param pos Image positioning: - 0 not rotated, not flipped, - 1 rotated 90 degree counterclockwise, not flipped, - 2 rotated 180 degree counterclockwise, not flipped, - 3 rotated 270 degree counterclockwise, not flipped, - 4 not rotated, flipped, - 5 rotated 90 degree counterclockwise, flipped, - 6 rotated 180 degree counterclockwise, flipped, - 7 rotated 270 degree counterclockwise, flipped. @param ifl Image flags. @param bbptr Bounding box, may be NULL. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_bif_fig_image( dk4_gra_t *gra, double xl, double xr, double yb, double yt, dk4_bif_t *bif, const dkChar *fn, size_t fno, int pos, int ifl, dk4_bb_t *bbptr, int *backptr, dk4_app_t *app ); /** Add bitmap image. @param gra Output structure. @param xl Left x coordinate. @param xr Right x coordinate. @param yb Bottom y coordinate. @param yt Top y coordinate. @param bif Bitmap image file data. @param fn Image file name. @param fno Frame number (0 for first frame). @param ifl Image flags. @param bbptr Bounding box, may be NULL. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_bif_image( dk4_gra_t *gra, double xl, double xr, double yb, double yt, dk4_bif_t *bif, const dkChar *fn, size_t fno, int ifl, dk4_bb_t *bbptr, int *backptr, dk4_app_t *app ); /** Add bitmap image. @param gra Output structure. @param xl Left x coordinate. @param xr Right x coordinate. @param yb Bottom y coordinate. @param yt Top y coordinate. @param fn Image file name. @param fno Frame number (0 for first frame). @param ctx Bitmap image conversion context, may be NULL. @param ifl Image flags. @param bbptr Bounding box, may be NULL. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_image( dk4_gra_t *gra, double xl, double xr, double yb, double yt, const dkChar *fn, size_t fno, dk4_cs_conv_ctx_t *ctx, int ifl, dk4_bb_t *bbptr, int *backptr, dk4_app_t *app ); /** Add bitmap image XFig style. @param gra Output structure. @param xl Left x coordinate. @param xr Right x coordinate. @param yb Bottom y coordinate. @param yt Top y coordinate. @param fn Image file name. @param fno Frame number (0 for first frame). @param ctx Bitmap image conversion context, may be NULL. @param pos Image positioning: - 0 not rotated, not flipped, - 1 rotated 90 degree counterclockwise, not flipped, - 2 rotated 180 degree counterclockwise, not flipped, - 3 rotated 270 degree counterclockwise, not flipped, - 4 not rotated, flipped, - 5 rotated 90 degree counterclockwise, flipped, - 6 rotated 180 degree counterclockwise, flipped, - 7 rotated 270 degree counterclockwise, flipped. @param ifl Image flags. @param bbptr Bounding box, may be NULL. @param backptr Address of success variable to reset on errors. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_fig_image( dk4_gra_t *gra, double xl, double xr, double yb, double yt, const dkChar *fn, size_t fno, dk4_cs_conv_ctx_t *ctx, int pos, int ifl, dk4_bb_t *bbptr, int *backptr, dk4_app_t *app ); /** Set the font size for the documentclass line. @param gra Output structure, must be initialized for PGF. @param fs Font size in pt. @param backptr Address of success variable to reset on error. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_pgf_doc_font_size( dk4_gra_t *gra, double fs, int *backptr, dk4_app_t *app ); /** Add a preamble line. For font setup and package setup the lines added by this function replace the default contents. For other setup the lines added by this function are appended after the default contents. @param gra Output structure, must be initialized for PGF. @param line Line text without trailing newline. @param tp Line type: DK4_GRA_PREAMBLE_FONT, DK4_GRA_PREAMBLE_PACKAGE, or DK4_GRA_PREAMBLE_OTHER. @param backptr Address of success variable to reset on error. @param app Application structure for diagnostics, may be NULL. */ void dk4gra_app_pgf_doc_preamble_line( dk4_gra_t *gra, const char *line, int tp, int *backptr, dk4_app_t *app ); #ifdef __cplusplus } #endif /* vim: set ai sw=4 ts=4 : */ #endif