/* Contexts. Copyright (C) 2001 Johan Rydberg. All Rights Reserved. This file is part of Crust. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __GraphicsFoundation_GFContext_h #define __GraphicsFoundation_GFContext_h 1 #include #include #include /* Opaque type for a reference to a context. */ typedef struct GFContext *GFContextRef; /* Drawing modes for GFContextDrawPath. */ enum _GFPathDrawingMode { kGFPathStroke = 0x00000001, kGFPathFill = 0x00000010, kGFPathEOFill = 0x00000030, kGFPathFillStroke = 0x00000011, kGFPathEOFillStroke = 0x00000031 }; typedef enum _GFPathDrawingMode GFPathDrawingMode; /* Begin a new path. The old path is destroyed. */ GF_EXTERN void GFContextBeginPath (GFContextRef context); /* Close current subpath in CONTEXT. */ GF_EXTERN void GFContextClosePath (GFContextRef context); /* Move current point to (X, Y). Opens a new subpath. */ GF_EXTERN void GFContextMoveToPoint (GFContextRef context, float x, float y); /* Add a line from current point to (X, Y). */ GF_EXTERN void GFContextAddLineToPoint (GFContextRef context, float x, float y); /* Add a beizer curve from current point to (X0, Y0). (X1, Y1) and (X2, Y2) is control points for the curve. */ GF_EXTERN void GFContextAddCurveToPoint (GFContextRef context, float x1, float y1, float x2, float y2, float x0, float y0); /* Add a quadratic curve from current point to (X0, Y0). (X1, Y1) is the control point for the curve. */ GF_EXTERN void GFContextAddQuadCurveToPoint (GFContextRef ctx, float x1, float y1, float x0, float y0); /* Draw path in CONTEXT according to drawing mode specified in MODE. */ GF_EXTERN void GFContextDrawPath (GFContextRef context, GFPathDrawingMode mode); /* Convenience function for filling a path. */ GF_EXTERN void GFContextFillPath (GFContextRef context); /* Convenience function for filling a path with even-odd winding rule. */ GF_EXTERN void GFContextEOFillPath (GFContextRef context); /* Convenience function for stroking a path. */ GF_EXTERN void GFContextStrokePath (GFContextRef context); /* Set alpha value for context to VALUE. */ void GFContextSetAlpha (GFContextRef context, float value); /* Set fill color to VALUE. Number of components in VALUE is specifed by current fill color space. */ GF_EXTERN void GFContextSetFillColor (GFContextRef context, float value[]); /* Set fill color space in graphic state for CONTEXT to COLORSPACE. */ GF_EXTERN void GFContextSetFillColorSpace (GFContextRef context, GFColorSpaceRef colorspace); /* Set stroke color to VALUE. Number of components in VALUE is specified by current stroke color space. */ GF_EXTERN void GFContextSetStrokeColor (GFContextRef context, float value[]); /* Set stroke color space in graphic state for CONTEXT to COLORSPACE. */ GF_EXTERN void GFContextSetStrokeColorSpace (GFContextRef context, GFColorSpaceRef colorspace); /* Convenience function for setting fill color to (R, G, B) and fill color space to DeviceRGB. Sets alpha value to ALPHA. */ GF_EXTERN void GFContextSetRGBFillColor (GFContextRef context, float r, float g, float b, float alpha); /* Convenience function for setting stroke color to (R, G, B) and stroke color space to DeviceRGB. Sets alpha value to ALPHA. */ GF_EXTERN void GFContextSetRGBStrokeColor (GFContextRef context, float r, float g, float b, float alpha); /* Sets line width for CONTEXTs graphic state to LINE_WIDTH. */ GF_EXTERN void GFContextSetLineWidth (GFContextRef context, float line_width); /* Set line caption for CONTEXTs graphic state to LINE_CAP. */ GF_EXTERN void GFContextSetLineCap(GFContextRef context, int line_cap); /* Set line join for CONTEXTs graphic state to LINE_JOIN. */ GF_EXTERN void GFContextSetLineJoin(GFContextRef context, int line_join); /* Scale CTM according to SX and SY. */ GF_EXTERN void GFContextScaleCTM (GFContextRef context, float sx, float sy); /* Rotate CTM with TH radians. */ GF_EXTERN void GFContextRotateCTM (GFContextRef context, float th); /* Restore saved graphic state on graphic state stack in CONTEXT. */ GF_EXTERN void GFContextRestoreGState (GFContextRef context); /* Save graphic state on graphic state stack in CONTEXT. */ GF_EXTERN void GFContextSaveGState (GFContextRef context); #endif /* GFContext.h */