1 /*******************************************************************************
2 **3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
3 ** 10 20 30 40 50 60 70 80
9 ** Mirco "MacSlow" Mueller <macslow@bangang.de>
11 ** copyright (C) Mirco Mueller, July 2006, placed under the terms of the LGPL
13 *******************************************************************************/
20 #include "cairo-rendering.h"
23 create_cairo_context (int iWidth
,
26 cairo_surface_t
** pSurface
,
27 unsigned char** pucBuffer
)
29 cairo_t
* pCairoContext
= NULL
;
31 /* create cairo-surface/context to act as OpenGL-texture source */
32 *pucBuffer
= calloc (iChannels
* iWidth
* iHeight
, sizeof (unsigned char));
35 printf ("create_cairo_context() - Couldn't allocate surface-buffer\n");
39 *pSurface
= cairo_image_surface_create_for_data (*pucBuffer
,
44 if (cairo_surface_status (*pSurface
) != CAIRO_STATUS_SUCCESS
)
47 printf ("create_cairo_context() - Couldn't create surface\n");
51 pCairoContext
= cairo_create (*pSurface
);
52 if (cairo_status (pCairoContext
) != CAIRO_STATUS_SUCCESS
)
55 printf ("create_cairo_context() - Couldn't create context\n");
63 render_curve (cairo_t
* pCairoContext
,
70 if (pLineOne
== NULL
|| pLineTwo
== NULL
)
73 cairo_save (pCairoContext
);
74 cairo_set_operator (pCairoContext
, CAIRO_OPERATOR_OVER
);
75 cairo_scale (pCairoContext
, (double) iWidth
/ 1.0f
, (double) iHeight
/ 1.0f
);
76 cairo_set_source_rgba (pCairoContext
, 0.0f
, 1.0f
, 0.0f
, 1.0f
);
77 cairo_paint (pCairoContext
);
79 cairo_set_source_rgba (pCairoContext
, 0.0f
, 0.0f
, 0.0f
, 1.0f
);
80 cairo_set_line_cap (pCairoContext
, CAIRO_LINE_CAP_ROUND
);
81 cairo_set_line_width (pCairoContext
, fLineWidth
);
82 cairo_move_to (pCairoContext
, pLineOne
->start
.fX
, pLineOne
->start
.fY
);
83 cairo_curve_to (pCairoContext
,
90 cairo_stroke (pCairoContext
);
91 cairo_restore (pCairoContext
);