cairo/xr.c

263 lines
5 KiB
C
Raw Normal View History

2002-06-11 04:02:23 +00:00
/*
* $XFree86: $
*
* Copyright <EFBFBD> 2002 Carl D. Worth
2002-06-11 04:02:23 +00:00
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies
* and that both that copyright notice and this permission notice
* appear in supporting documentation, and that the name of Carl
* D. Worth not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior
* permission. Carl D. Worth makes no representations about the
* suitability of this software for any purpose. It is provided "as
* is" without express or implied warranty.
2002-06-11 04:02:23 +00:00
*
* CARL D. WORTH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL CARL D. WORTH BE LIABLE FOR ANY SPECIAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
2002-06-11 04:02:23 +00:00
#include "xrint.h"
XrState *
XrCreate(Display *dpy)
2002-06-11 04:02:23 +00:00
{
return XrStateCreate(dpy);
2002-06-11 04:02:23 +00:00
}
void
XrDestroy(XrState *xrs)
{
XrStateDestroy(xrs);
}
void
XrSave(XrState *xrs)
{
XrError err;
err = XrStatePush(xrs);
if (err)
xrs->error = err;
2002-06-11 04:02:23 +00:00
}
void
XrRestore(XrState *xrs)
{
XrStatePop(xrs);
}
void
XrSetDrawable(XrState *xrs, Drawable drawable)
{
XrGStateSetDrawable(CURRENT_GSTATE(xrs), drawable);
}
void
XrSetVisual(XrState *xrs, Visual *visual)
{
XrGStateSetVisual(CURRENT_GSTATE(xrs), visual);
}
void
XrSetFormat(XrState *xrs, XrFormat format)
2002-06-11 04:02:23 +00:00
{
XrGStateSetFormat(CURRENT_GSTATE(xrs), format);
2002-06-11 04:02:23 +00:00
}
2002-07-23 07:22:23 +00:00
void
XrSetOperator(XrState *xrs, XrOperator operator)
{
XrGStateSetOperator(CURRENT_GSTATE(xrs), operator);
}
2002-06-11 04:02:23 +00:00
void
XrSetRGBColor(XrState *xrs, double red, double green, double blue)
2002-06-11 04:02:23 +00:00
{
2002-07-23 07:22:23 +00:00
XrGStateSetRGBColor(CURRENT_GSTATE(xrs), red, green, blue);
2002-06-11 04:02:23 +00:00
}
void
XrSetAlpha(XrState *xrs, double alpha)
{
XrGStateSetAlpha(CURRENT_GSTATE(xrs), alpha);
}
void
XrSetLineWidth(XrState *xrs, double width)
{
XrGStateSetLineWidth(CURRENT_GSTATE(xrs), width);
2002-07-23 07:22:23 +00:00
}
void
XrSetLineCap(XrState *xrs, XrLineCap line_cap)
{
XrGStateSetLineCap(CURRENT_GSTATE(xrs), line_cap);
}
void
XrSetLineJoin(XrState *xrs, XrLineJoin line_join)
{
XrGStateSetLineJoin(CURRENT_GSTATE(xrs), line_join);
}
void
XrSetDash(XrState *xrs, double *dashes, int ndash, double offset)
{
XrError err;
err = XrGStateSetDash(CURRENT_GSTATE(xrs), dashes, ndash, offset);
if (err)
xrs->error = err;
}
2002-07-23 07:22:23 +00:00
void
XrSetMiterLimit(XrState *xrs, double limit)
{
XrGStateSetMiterLimit(CURRENT_GSTATE(xrs), limit);
2002-06-11 04:02:23 +00:00
}
void
XrTranslate(XrState *xrs, double tx, double ty)
{
XrGStateTranslate(CURRENT_GSTATE(xrs), tx, ty);
}
void
XrScale(XrState *xrs, double sx, double sy)
{
XrGStateScale(CURRENT_GSTATE(xrs), sx, sy);
}
void
XrRotate(XrState *xrs, double angle)
{
XrGStateRotate(CURRENT_GSTATE(xrs), angle);
}
void
XrNewPath(XrState *xrs)
{
XrGStateNewPath(CURRENT_GSTATE(xrs));
}
void
XrMoveTo(XrState *xrs, double x, double y)
{
XrError err;
err = XrGStateAddUnaryPathOp(CURRENT_GSTATE(xrs), XrPathOpMoveTo, x, y);
if (err)
xrs->error = err;
2002-06-11 04:02:23 +00:00
}
void
XrLineTo(XrState *xrs, double x, double y)
{
XrError err;
err = XrGStateAddUnaryPathOp(CURRENT_GSTATE(xrs), XrPathOpLineTo, x, y);
if (err)
xrs->error = err;
}
void
XrCurveTo(XrState *xrs,
double x1, double y1,
double x2, double y2,
double x3, double y3)
{
XrError err;
XPointDouble pt[3];
pt[0].x = x1; pt[0].y = y1;
pt[1].x = x2; pt[1].y = y2;
pt[2].x = x3; pt[2].y = y3;
err = XrGStateAddPathOp(CURRENT_GSTATE(xrs), XrPathOpCurveTo, pt, 3);
if (err)
xrs->error = err;
2002-06-11 04:02:23 +00:00
}
void
XrRelMoveTo(XrState *xrs, double x, double y)
{
XrError err;
err = XrGStateAddUnaryPathOp(CURRENT_GSTATE(xrs), XrPathOpRelMoveTo, x, y);
if (err)
xrs->error = err;
2002-06-11 04:02:23 +00:00
}
void
XrRelLineTo(XrState *xrs, double x, double y)
{
XrError err;
err = XrGStateAddUnaryPathOp(CURRENT_GSTATE(xrs), XrPathOpRelLineTo, x, y);
if (err)
xrs->error = err;
}
void
XrRelCurveTo(XrState *xrs,
double x1, double y1,
double x2, double y2,
double x3, double y3)
{
XrError err;
XPointDouble pt[3];
pt[0].x = x1; pt[0].y = y1;
pt[1].x = x2; pt[1].y = y2;
pt[2].x = x3; pt[2].y = y3;
err = XrGStateAddPathOp(CURRENT_GSTATE(xrs), XrPathOpRelCurveTo, pt, 3);
if (err)
xrs->error = err;
2002-06-11 04:02:23 +00:00
}
void
XrClosePath(XrState *xrs)
{
XrError err;
err = XrGStateClosePath(CURRENT_GSTATE(xrs));
if (err)
xrs->error = err;
2002-06-11 04:02:23 +00:00
}
void
XrStroke(XrState *xrs)
{
XrError err;
if (xrs->error)
return;
err = XrGStateStroke(CURRENT_GSTATE(xrs));
if (err)
xrs->error = err;
2002-06-11 04:02:23 +00:00
}
void
XrFill(XrState *xrs)
{
XrError err;
if (xrs->error)
return;
XrClosePath(xrs);
2002-06-11 04:02:23 +00:00
err = XrGStateFill(CURRENT_GSTATE(xrs));
if (err) {
xrs->error = err;
}
}