1 /*
2  rl2graphics.h -- RasterLite2 common graphics support
3 
4  version 2.0, 2013 September 29
5 
6  Author: Sandro Furieri a.furieri@lqt.it
7 
8  ------------------------------------------------------------------------------
9 
10  Version: MPL 1.1/GPL 2.0/LGPL 2.1
11 
12  The contents of this file are subject to the Mozilla Public License Version
13  1.1 (the "License"); you may not use this file except in compliance with
14  the License. You may obtain a copy of the License at
15  http://www.mozilla.org/MPL/
16 
17 Software distributed under the License is distributed on an "AS IS" basis,
18 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
19 for the specific language governing rights and limitations under the
20 License.
21 
22 The Original Code is the RasterLite2 library
23 
24 The Initial Developer of the Original Code is Alessandro Furieri
25 
26 Portions created by the Initial Developer are Copyright (C) 2013
27 the Initial Developer. All Rights Reserved.
28 
29 Contributor(s):
30 
31 
32 Alternatively, the contents of this file may be used under the terms of
33 either the GNU General Public License Version 2 or later (the "GPL"), or
34 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
35 in which case the provisions of the GPL or the LGPL are applicable instead
36 of those above. If you wish to allow use of your version of this file only
37 under the terms of either the GPL or the LGPL, and not to allow others to
38 use your version of this file under the terms of the MPL, indicate your
39 decision by deleting the provisions above and replace them with the notice
40 and other provisions required by the GPL or the LGPL. If you do not delete
41 the provisions above, a recipient may use your version of this file under
42 the terms of any one of the MPL, the GPL or the LGPL.
43 
44 */
45 
46 /**
47  \file rl2graphics.h
48 
49  Graphics (Cairo) support
50  */
51 
52 #ifndef _RL2GRAPHICS_H
53 #ifndef DOXYGEN_SHOULD_SKIP_THIS
54 #define _RL2GRAPHICS_H
55 #endif
56 
57 #ifdef __cplusplus
58 extern "C"
59 {
60 #endif
61 
62 #define RL2_PENSTYLE_SOLID	5001
63 #define RL2_PENSTYLE_DOT	5002
64 #define RL2_PENSTYLE_LONG_DASH 	5003
65 #define RL2_PENSTYLE_SHORT_DASH	5004
66 #define RL2_PENSTYLE_DOT_DASH	5005
67 
68 #define RL2_FONTSTYLE_NORMAL	5101
69 #define RL2_FONTSTYLE_ITALIC	5102
70 
71 #define RL2_FONTWEIGHT_NORMAL	5201
72 #define RL2_FONTWEIGHT_BOLD	5202
73 
74 #define RL2_CLEAR_PATH		5100
75 #define RL2_PRESERVE_PATH	5101
76 
77     typedef struct rl2_graphics_context rl2GraphicsContext;
78     typedef rl2GraphicsContext *rl2GraphicsContextPtr;
79 
80     typedef struct rl2_graphics_pattern rl2GraphicsPattern;
81     typedef rl2GraphicsPattern *rl2GraphicsPatternPtr;
82 
83     typedef struct rl2_graphics_font rl2GraphicsFont;
84     typedef rl2GraphicsFont *rl2GraphicsFontPtr;
85 
86     typedef struct rl2_graphics_bitmap rl2GraphicsBitmap;
87     typedef rl2GraphicsBitmap *rl2GraphicsBitmapPtr;
88 
89 /**
90  Creates a generic Graphics Context
91 
92  \param width canvass width (in pixels)
93  \param height canvass height (in pixels)
94 
95  \return the pointer to the corresponding Graphics Context object: NULL on failure
96 
97  \sa rl2_graph_destroy_context, rl2_graph_create_svg_context,
98  rl2_graph_create_pdf_context, rl2_graph_create_mem_pdf_context
99 
100  \note you are responsible to destroy (before or after) any Graphics Context
101  returned by rl2_graph_create_context() by invoking rl2_graph_destroy_context().
102  */
103     RL2_DECLARE rl2GraphicsContextPtr rl2_graph_create_context (int width,
104 								int height);
105 
106 /**
107  Destroys a Graphics Context object freeing any allocated resource
108 
109  \param handle the pointer to a valid Graphics Context returned by a previous call
110  to rl2_graph_create_context()
111 
112  \sa rl2_graph_create_context
113  */
114     RL2_DECLARE void rl2_graph_destroy_context (rl2GraphicsContextPtr context);
115 
116 /**
117  Creates an SVG Graphics Context
118 
119  \param path pathname of the target SVG output file
120  \param width canvass width (in pixels)
121  \param height canvass height (in pixels)
122 
123  \return the pointer to the corresponding Graphics Context object: NULL on failure
124 
125  \sa rl2_graph_create_context, rl2_graph_destroy_context, rl2_graph_create_pdf_context,
126  rl2_graph_create_mem_pdf_context
127 
128  \note you are responsible to destroy (before or after) any SVG Graphics Context
129  returned by rl2_graph_create_svg_context() by invoking rl2_graph_destroy_context().
130  */
131     RL2_DECLARE rl2GraphicsContextPtr rl2_graph_create_svg_context (const char
132 								    *path,
133 								    int width,
134 								    int height);
135 
136 /**
137  Creates a PDF Graphics Context
138 
139  \param path pathname of the target PDF output file
140  \param dpi the PDF printing resolution measured in DPI
141  \param page_width total page width (in inches) including any margin
142  \param page_height total page height (in inches) including any margin
143  \param margin_width horizontal margin width (in inches)
144  \param margin_height vertical margin height (in inches)
145 
146  \return the pointer to the corresponding Graphics Context object: NULL on failure
147 
148  \sa rl2_graph_create_context, rl2_graph_create_svg_context, rl2_graph_create_mem_pdf_context,
149  rl2_graph_destroy_context
150 
151  \note you are responsible to destroy (before or after) any PDF Graphics Context
152  returned by rl2_graph_create_pdf_context() by invoking rl2_graph_destroy_context().
153  */
154     RL2_DECLARE rl2GraphicsContextPtr rl2_graph_create_pdf_context (const char
155 								    *path,
156 								    int dpi,
157 								    double
158 								    page_width,
159 								    double
160 								    page_height,
161 								    double
162 								    margin_width,
163 								    double
164 								    margin_height);
165 
166 /**
167  Creates an in-memory PDF Graphics Context
168 
169  \param mem handle to an in-memory PDF target create by rl2_create_mem_pdf_target()
170  \param dpi the PDF printing resolution measured in DPI
171  \param page_width total page width (in inches) including any margin
172  \param page_height total page height (in inches) including any margin
173  \param margin_width horizontal margin width (in inches)
174  \param margin_height vertical margin height (in inches)
175 
176  \return the pointer to the corresponding Graphics Context object: NULL on failure
177 
178  \sa rl2_graph_create_context, rl2_graph_create_svg_context, rl2_graph_create_pdf_context,
179  rl2_graph_destroy_context, rl2_create_mem_pdf_target
180 
181  \note you are responsible to destroy (before or after) any PDF Graphics Context
182  returned by rl2_graph_create_mem_pdf_context() by invoking rl2_graph_destroy_context().
183  */
184     RL2_DECLARE rl2GraphicsContextPtr
185 	rl2_graph_create_mem_pdf_context (rl2MemPdfPtr pdf, int dpi,
186 					  double page_width, double page_height,
187 					  double margin_width,
188 					  double margin_height);
189 
190 /**
191  Create an in-memory PDF target
192 
193  \return the handle to an initially empty in-memory PDF target: NULL on failure
194 
195  \sa rl2_graph_create_mem_pdf_context, rl2_destroy_mem_pdf_target,
196  rl2_get_mem_pdf_buffer
197 
198  \note you are responsible to destroy (before or after) any in-memory PDF target
199  returned by rl2_create_mem_pdf_target() by invoking rl2_destroy_mem_pdf_target().
200  */
201     RL2_DECLARE rl2MemPdfPtr rl2_create_mem_pdf_target (void);
202 
203 /**
204  Destroys an in-memory PDF target freeing any allocated resource
205 
206  \param handle the pointer to a valid in-memory PDF target returned by a previous call
207  to rl2_create_mem_pdf_target()
208 
209  \sa rl2_create_mem_pdf_target, rl2_destroy_mem_pdf_target
210  */
211     RL2_DECLARE void rl2_destroy_mem_pdf_target (rl2MemPdfPtr target);
212 
213 /**
214  Transfers the ownership of the memory buffer contained into a in-memory PDF target
215 
216  \param handle the pointer to a valid in-memory PDF target returned by a previous call
217  to rl2_create_mem_pdf_target()
218  \param buffer on completion this variable will point to the a memory block
219   containing the PDF document (may be NULL if any error occurred).
220  \param size on completion this variable will contain the size (in bytes)
221  of the memory block containing the PDF document.
222 
223  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
224  including referencing an empty in-memory PDF target).
225 
226  \sa rl2_create_mem_pdf_target
227 
228  \note after invoking rl2_get_mem_pdf_buffer() the in-memory PDF target
229  will be reset to its initial empty state-
230  */
231     RL2_DECLARE int rl2_get_mem_pdf_buffer (rl2MemPdfPtr target,
232 					    unsigned char **buffer, int *size);
233 
234 /**
235  Selects the currently set Pen for a Graphics Context
236 
237  \param context the pointer to a valid Graphics Context returned by a previous call
238  to rl2_graph_create_context(), rl2_graph_create_svg_context() or
239  rl2_graph_create_pdf_context()
240  \param red Pen color: red component.
241  \param green Pen color: green component.
242  \param blue Pen color: blue component.
243  \param alpha Pen transparency (0 full transparent; 255 full opaque).
244  \param width Pen width
245  \param style one of RL2_PENSTYLE_SOLID, RL2_PENSTYLE_DOT, RL2_PENSTYLE_LONG_DASH,
246  RL2_PENSTYLE_SHORT_DASH, RL2_PENSTYLE_DOT_DASH
247 
248  \return 0 (false) on error, any other value on success.
249 
250  \sa rl2_graph_create_context, rl2_graph_create_svg_context,
251  rl2_graph_create_pdf_context, rl2_graph_set_brush,
252  rl2_graph_set_linear_gradient_brush, rl2_graph_set_pattern_brush,
253  rl2_graph_set_font
254  */
255     RL2_DECLARE int rl2_graph_set_pen (rl2GraphicsContextPtr context,
256 				       unsigned char red, unsigned char green,
257 				       unsigned char blue, unsigned char alpha,
258 				       double width, int style);
259 
260 /**
261  Selects the currently set Brush for a Graphics Context
262 
263  \param context the pointer to a valid Graphics Context returned by a previous call
264  to rl2_graph_create_context(), rl2_graph_create_svg_context() or
265  rl2_graph_create_pdf_context()
266  \param red Brush color: red component.
267  \param green Brush color: green component.
268  \param blue Brush color: blue component.
269  \param alpha Brush transparency (0 full transparent; 255 full opaque).
270 
271  \return 0 (false) on error, any other value on success.
272 
273  \sa rl2_graph_create_context, rl2_graph_create_svg_context,
274  rl2_graph_create_pdf_context, rl2_graph_set_pen,
275  rl2_graph_set_linear_gradient_brush, rl2_graph_set_pattern_brush,
276  rl2_graph_set_font
277 
278  \note a Brush created by this function always is a solid Brush, may be
279  supporting transparency.
280  */
281     RL2_DECLARE int rl2_graph_set_brush (rl2GraphicsContextPtr context,
282 					 unsigned char red, unsigned char green,
283 					 unsigned char blue,
284 					 unsigned char alpha);
285 
286 /**
287  Selects the currently set Brush for a Graphics Context
288 
289  \param context the pointer to a valid Graphics Context returned by a previous call
290  to rl2_graph_create_context(), rl2_graph_create_svg_context() or
291  rl2_graph_create_pdf_context()
292  \param x start point (X coord, in pixels) of the Gradient.
293  \param y start point (Y coord, in pixels) of the Gradient.
294  \param width the Gradient width.
295  \param height the Gradient height.
296  \param red1 first Gradient color: red component.
297  \param green1 first Gradient color: green component.
298  \param blue1 first Gradient color: blue component.
299  \param alpha1 first Gradient color transparency (0 full transparent; 255 full opaque).
300  \param red2 second Gradient color: red component.
301  \param green2 second Gradient color: green component.
302  \param blue2 second Gradient color: blue component.
303  \param alpha2 second Gradient color transparency (0 full transparent; 255 full opaque).
304 
305  \return 0 (false) on error, any other value on success.
306 
307  \sa rl2_graph_create_context, rl2_graph_create_svg_context,
308  rl2_graph_create_pdf_context, rl2_graph_set_pen,
309  rl2_graph_set_brush, rl2_graph_set_pattern_brush,
310  rl2_graph_set_font
311 
312  \note a Brush created by this function always is a Linear Gradient Brush.
313  */
314     RL2_DECLARE int rl2_graph_set_linear_gradient_brush (rl2GraphicsContextPtr,
315 							 double x, double y,
316 							 double width,
317 							 double height,
318 							 unsigned char red1,
319 							 unsigned char green1,
320 							 unsigned char blue1,
321 							 unsigned char alpha1,
322 							 unsigned char red2,
323 							 unsigned char green2,
324 							 unsigned char blue2,
325 							 unsigned char alpha2);
326 
327 /**
328  Selects the currently set Brush for a Graphics Context
329 
330  \param context the pointer to a valid Graphics Context returned by a previous call
331  to rl2_graph_create_context(), rl2_graph_create_svg_context() or
332  rl2_graph_create_pdf_context()
333  \param brush the pointer to a valid Graphics Pattern returned by a previous
334  call to rl2_graph_create_pattern().
335 
336  \return 0 (false) on error, any other value on success.
337 
338  \sa rl2_graph_create_context, rl2_graph_create_svg_context,
339  rl2_graph_create_pdf_context, rl2_graph_set_pen,
340  rl2_graph_set_brush, rl2_graph_set_linear_gradient_brush,
341  rl2_graph_set_font, rl2_create_pattern
342 
343  \note a Brush created by this function always is a Pattern Brush,
344  i.e. a Brush repeatedly using a small bitmap as a filling source.
345  */
346     RL2_DECLARE int rl2_graph_set_pattern_brush (rl2GraphicsContextPtr context,
347 						 rl2GraphicsPatternPtr brush);
348 
349 /**
350  Selects the currently set Font for a Graphics Context
351 
352  \param context the pointer to a valid Graphics Context returned by a previous call
353  to rl2_graph_create_context(), rl2_graph_create_svg_context() or
354  rl2_graph_create_pdf_context()
355  \param font the pointer to a valid Graphics Font returned by a previous call
356  to rl2_create_font().
357 
358  \return 0 (false) on error, any other value on success.
359 
360  \sa rl2_graph_create_context, rl2_graph_create_svg_context,
361  rl2_graph_create_pdf_context, rl2_graph_set_pen, rl2_graph_set_brush,
362  rl2_graph_set_linear_gradient_brush, rl2_graph_set_pattern_brush,
363  rl2_create_font
364  */
365     RL2_DECLARE int rl2_graph_set_font (rl2GraphicsContextPtr context,
366 					rl2GraphicsFontPtr font);
367 
368 /**
369  Creates a Pattern Brush
370 
371  \param rgbaArray pointer to an array of RGBA pixels representing the bitmap
372  supporting the Pattern Brush to be created.
373  \param width Pattern width (in pixels)
374  \param height Pattern height (in pixels)
375 
376  \return the pointer to the corresponding Pattern Brush object: NULL on failure
377 
378  \sa rl2_graph_set_pattern_brush, rl2_graph_destroy_brush
379 
380  \note you are responsible to destroy (before or after) any Pattern Brush
381  returned by rl2_graph_create_pattern() by invoking rl2_graph_destroy_pattern().
382  */
383     RL2_DECLARE rl2GraphicsPatternPtr rl2_graph_create_pattern (unsigned char
384 								*rgbaArray,
385 								int width,
386 								int height);
387 
388 /**
389  Destroys a Pattern Brush object freeing any allocated resource
390 
391  \param handle the pointer to a valid Pattern Brush returned by a previous call
392  to rl2_graph_create_pattern()
393 
394  \sa rl2_graph_create_pattern
395  */
396     RL2_DECLARE void rl2_graph_destroy_pattern (rl2GraphicsPatternPtr pattern);
397 
398 /**
399  Creates a Graphics Font Object
400 
401  \param size the Graphics Font size (in points).
402  \param style one of RL2_FONTSTYLE_NORMAL or RL2_FONTSTYLE_ITALIC
403  \param weight one of RL2_FONTWEIGHT_NORMAL or RL2_FONTWEIGHT_BOLD
404 
405  \return the pointer to the corresponding Font object: NULL on failure
406 
407  \sa rl2_graph_set_font, rl2_graph_destroy_font, rl2_graph_font_set_color,
408  rl2_graph_font_set_color, rl2_graph_font_set_outline
409 
410  \note you are responsible to destroy (before or after) any Pattern Brush
411  returned by rl2_graph_create_font() by invoking rl2_graph_destroy_font().
412  */
413     RL2_DECLARE rl2GraphicsFontPtr rl2_graph_create_font (double size,
414 							  int style,
415 							  int weight);
416 
417 /**
418  Destroys a Graphics Font object freeing any allocated resource
419 
420  \param handle the pointer to a valid Font returned by a previous call
421  to rl2_graph_create_font()
422 
423  \sa rl2_graph_create_font
424  */
425     RL2_DECLARE void rl2_graph_destroy_font (rl2GraphicsFontPtr font);
426 
427 /**
428  Selects the currently set Color for a Graphics Font
429 
430  \param font the pointer to a valid Graphics Font returned by a previous call
431  to rl2_graph_create_font()
432  \param red Font color: red component.
433  \param green Font color: green component.
434  \param blue Font color: blue component.
435  \param alpha Font transparency (0 full transparent; 255 full opaque).
436 
437  \return 0 (false) on error, any other value on success.
438 
439  \sa rl2_graph_create_font, rl2_graph_font_set_outline,
440  rl2_graph_set_font
441  */
442     RL2_DECLARE int rl2_graph_font_set_color (rl2GraphicsFontPtr font,
443 					      unsigned char red,
444 					      unsigned char green,
445 					      unsigned char blue,
446 					      unsigned char alpha);
447 
448 /**
449  Selects the currently set Outline for a Graphics Font
450 
451  \param font the pointer to a valid Graphics Font returned by a previous call
452  to rl2_graph_create_font()
453  \param width the outline width (in points); declaring a zero or negative value
454  will remove any outline from the Font.
455 
456  \return 0 (false) on error, any other value on success.
457 
458  \sa rl2_graph_create_font, rl2_graph_font_set_color,
459  rl2_graph_set_font
460  */
461     RL2_DECLARE int rl2_graph_font_set_outline (rl2GraphicsFontPtr font,
462 						double width);
463 
464 /**
465  Creates a Graphics Bitmap
466 
467  \param rgbaArray pointer to an array of RGBA pixels representing the bitmap.
468  \param width Bitmap width (in pixels)
469  \param height Bitmap height (in pixels)
470 
471  \return the pointer to the corresponding Graphics Bitmap object: NULL on failure
472 
473  \sa rl2_graph_destroy_bitmap
474 
475  \note you are responsible to destroy (before or after) any Graphics Bitmap
476  returned by rl2_graph_create_bitmap() by invoking rl2_graph_destroy_bitmap().
477  */
478     RL2_DECLARE rl2GraphicsBitmapPtr rl2_graph_create_bitmap (unsigned char
479 							      *rgbaArray,
480 							      int width,
481 							      int height);
482 
483 /**
484  Destroys a Graphics Bitmap object freeing any allocated resource
485 
486  \param handle the pointer to a valid Font returned by a previous call
487  to rl2_graph_create_bitmap()
488 
489  \sa rl2_graph_create_bitmap
490  */
491     RL2_DECLARE void rl2_graph_destroy_bitmap (rl2GraphicsBitmapPtr bitmap);
492 
493 /**
494  Drawing a Rectangle into a canvass
495 
496  \param context the pointer to a valid Graphics Context (aka Canvass).
497  \param x the X coordinate of the top left corner of the rectangle.
498  \param y the Y coordinate of the top left corner of the rectangle.
499  \param width the width of the rectangle.
500  \param height the height of the rectangle.
501 
502  \return 0 (false) on error, any other value on success.
503 
504  \sa rl2_graph_set_pen, rl2_graph_set_brush, rl2_graph, draw_rectangle,
505  rl2_graph_draw_ellipse, rl2_graph_draw_circle_sector, rl2_graph_stroke_line,
506  rl2_graph_fill_path, rl2_graph_stroke_path
507 
508  \note the rectangle will be stroked using the current Pen and will
509  be filled using the current Brush.
510  */
511     RL2_DECLARE int rl2_graph_draw_rectangle (rl2GraphicsContextPtr context,
512 					      double x, double y, double width,
513 					      double height);
514 
515 /**
516  Drawing a Rectangle with rounded corners into a canvass
517 
518  \param context the pointer to a valid Graphics Context (aka Canvass).
519  \param x the X coordinate of the top left corner of the rectangle.
520  \param y the Y coordinate of the top left corner of the rectangle.
521  \param width the width of the rectangle.
522  \param height the height of the rectangle.
523  \param radius used for rounded corners.
524 
525  \return 0 (false) on error, any other value on success.
526 
527  \sa rl2_graph_set_pen, rl2_graph_set_brush, rl2_draw_rectangle,
528  rl2_graph_draw_ellipse, rl2_graph_draw_circle_sector, rl2_graph_stroke_line,
529  rl2_graph_fill_path, rl2_graph_stroke_path
530 
531  \note the rectangle will be stroked using the current Pen and will
532  be filled using the current Brush.
533  */
534     RL2_DECLARE int rl2_graph_draw_rounded_rectangle (rl2GraphicsContextPtr
535 						      context, double x,
536 						      double y, double width,
537 						      double height,
538 						      double radius);
539 
540 /**
541  Drawing an Ellipse into a canvass
542 
543  \param context the pointer to a valid Graphics Context (aka Canvass).
544  \param x the X coordinate of the top left corner of the rectangle
545  into which the ellipse is inscribed.
546  \param y the Y coordinate of the top left corner of the rectangle.
547  \param width the width of the rectangle.
548  \param height the height of the rectangle.
549 
550  \return 0 (false) on error, any other value on success.
551 
552  \sa rl2_graph_set_pen, rl2_graph_set_brush, rl2_draw_rectangle,
553  rl2_graph_draw_rounded_rectangle, rl2_graph_draw_circle_sector,
554  rl2_graph_stroke_line, rl2_graph_fill_path, rl2_graph_stroke_path
555 
556  \note the ellipse will be stroked using the current Pen and will
557  be filled using the current Brush.
558  */
559     RL2_DECLARE int rl2_graph_draw_ellipse (rl2GraphicsContextPtr context,
560 					    double x, double y, double width,
561 					    double height);
562 
563 /**
564  Drawing a Circular Sector into a canvass
565 
566  \param context the pointer to a valid Graphics Context (aka Canvass).
567  \param center_x the X coordinate of the circle's centre.
568  \param center_y the Y coordinate of the circle's centre.
569  \param radius the circle's radius.
570  \param from_angle the angle (in degrees) at wich the sector starts.
571  \param to_angle the angle (in degrees) at wich the sector ends.
572 
573  \return 0 (false) on error, any other value on success.
574 
575  \sa rl2_graph_set_pen, rl2_graph_set_brush, rl2_draw_rectangle,
576  rl2_graph_draw_rounded_rectangle, rl2_graph_draw_ellipse,
577  rl2_graph_stroke_line, rl2_graph_fill_path, rl2_graph_stroke_path
578 
579  \note the Sector will be stroked using the current Pen and will
580  be filled using the current Brush.
581  */
582     RL2_DECLARE int rl2_graph_draw_circle_sector (rl2GraphicsContextPtr context,
583 						  double center_x,
584 						  double center_y,
585 						  double radius,
586 						  double from_angle,
587 						  double to_angle);
588 
589 /**
590  Drawing a straight Line into a canvass
591 
592  \param context the pointer to a valid Graphics Context (aka Canvass).
593  \param x0 the X coordinate of the first point.
594  \param y0 the Y coordinate of the first point.
595  \param x1 the X coordinate of the second point.
596  \param y1 the Y coordinate of the second point.
597 
598  \return 0 (false) on error, any other value on success.
599 
600  \sa rl2_graph_set_pen, rl2_graph_set_brush, rl2_draw_rectangle,
601  rl2_graph_draw_rounded_rectangle, rl2_graph_draw_ellipse,
602  rl2_graph_draw_circular_sector, rl2_graph_fill_path, rl2_graph_stroke_path
603 
604  \note the Sector will be stroked using the current Pen and will
605  be filled using the current Brush.
606  */
607     RL2_DECLARE int rl2_graph_stroke_line (rl2GraphicsContextPtr context,
608 					   double x0, double y0, double x1,
609 					   double y1);
610 
611 /**
612  Begins a new SubPath
613 
614  \param context the pointer to a valid Graphics Context (aka Canvass).
615  \param x the X coordinate of the point.
616  \param y the Y coordinate of the point.
617 
618  \return 0 (false) on error, any other value on success.
619 
620  \sa rl2_graph_set_pen, rl2_graph_set_brush, rl2_graph_add_line_to_path,
621  rl2_graph_close_subpath, rl2_graph_fill_path, rl2_graph_stroke_path
622  */
623     RL2_DECLARE int rl2_graph_move_to_point (rl2GraphicsContextPtr context,
624 					     double x, double y);
625 
626 /**
627  Add a line into the current SubPath
628 
629  \param context the pointer to a valid Graphics Context (aka Canvass).
630  \param x the X coordinate of the destination point.
631  \param y the Y coordinate of the destination point.
632 
633  \return 0 (false) on error, any other value on success.
634 
635  \sa rl2_graph_set_pen, rl2_graph_set_brush, rl2_graph_move_to_point,
636  rl2_graph_close_subpath, rl2_graph_fill_path, rl2_graph_stroke_path
637  */
638     RL2_DECLARE int rl2_graph_add_line_to_path (rl2GraphicsContextPtr context,
639 						double x, double y);
640 
641 /**
642  Terminates the current SubPath
643 
644  \param context the pointer to a valid Graphics Context (aka Canvass).
645 
646  \return 0 (false) on error, any other value on success.
647 
648  \sa rl2_graph_set_pen, rl2_graph_set_brush, rl2_graph_move_to_point,
649  rl2_graph_add_line_to_path, rl2_graph_fill_path, rl2_graph_stroke_path
650  */
651     RL2_DECLARE int rl2_graph_close_subpath (rl2GraphicsContextPtr context);
652 
653 /**
654  Fills the current Path using the currently set Brush
655 
656  \param context the pointer to a valid Graphics Context (aka Canvass).
657  \param preserve if true the current Path will be preserved into the
658  current Canvass, otherwise it will be definitely removed.
659 
660  \return 0 (false) on error, any other value on success.
661 
662  \sa rl2_graph_set_pen, rl2_graph_set_brush, rl2_graph_move_to_point,
663  rl2_graph_add_line_to_path, rl2_graph_close_subpath, rl2_graph_stroke_path
664  */
665     RL2_DECLARE int rl2_graph_fill_path (rl2GraphicsContextPtr context,
666 					 int preserve);
667 
668 /**
669  Strokes the current Path using the currently set Pen
670 
671  \param context the pointer to a valid Graphics Context (aka Canvass).
672  \param preserve if true the current Path will be preserved into the
673  current Canvass, otherwise it will be definitely removed.
674 
675  \return 0 (false) on error, any other value on success.
676 
677  \sa rl2_graph_set_pen, rl2_graph_set_brush, rl2_graph_move_to_point,
678  rl2_graph_add_line_to_path, rl2_graph_close_subpath, rl2_graph_fill_path
679  */
680     RL2_DECLARE int rl2_graph_stroke_path (rl2GraphicsContextPtr context,
681 					   int preserve);
682 
683 /**
684  Draws a text into the Canvass using the currently set Font
685 
686  \param context the pointer to a valid Graphics Context (aka Canvass).
687  \param text string to be printed into the canvass.
688  \param x the X coordinate of the top left corner of the text.
689  \param y the Y coordinate of the top left corner of the text.
690  \param angle an angle (in degrees) to rotate the text
691 
692  \return 0 (false) on error, any other value on success.
693 
694  \sa rl2_graph_set_font, rl2_graph_get_text_extent
695  */
696     RL2_DECLARE int rl2_graph_draw_text (rl2GraphicsContextPtr context,
697 					 const char *text, double x, double y,
698 					 double angle);
699 
700 /**
701  Computes the extent corresponding to a text into the Canvass using the currently set Font
702 
703  \param context the pointer to a valid Graphics Context (aka Canvass).
704  \param text string to be printed into the canvass.
705  \param pre_x on completion this variable will contain the horizontal
706   spacing before the text.
707  \param pre_y on completion this variable will contain the vertical
708   spacing before the text.
709  \param width on completion this variable will contain the width of
710  the printed text.
711  \param width on completion this variable will contain the height of
712  the printed text.
713  \param post_x on completion this variable will contain the horizontal
714   spacing after the text.
715  \param post_y on completion this variable will contain the vertical
716   spacing after the text.
717 
718  \return 0 (false) on error, any other value on success.
719 
720  \sa rl2_graph_set_font, rl2_graph_get_text_extent
721  */
722     RL2_DECLARE int rl2_graph_get_text_extent (rl2GraphicsContextPtr context,
723 					       const char *text, double *pre_x,
724 					       double *pre_y, double *width,
725 					       double *height, double *post_x,
726 					       double *post_y);
727 
728 /**
729  Draws a Bitmap into the Canvass
730 
731  \param context the pointer to a valid Graphics Context (aka Canvass).
732  \param bitmap the pointer to a valid Graphics Bitmap to be rendered.
733  \param x the X coordinate of the top left corner of the image.
734  \param y the Y coordinate of the top left corner of the image.
735 
736  \return 0 (false) on error, any other value on success.
737 
738  \sa rl2_graph_create_bitmap, rl2_graph_destroy_bitmap,
739  rl2_graph_draw_rescaled_bitmap
740  */
741     RL2_DECLARE int rl2_graph_draw_bitmap (rl2GraphicsContextPtr context,
742 					   rl2GraphicsBitmapPtr bitmap, int x,
743 					   int y);
744 
745 /**
746  Draws a Rescaled Bitmap into the Canvass
747 
748  \param context the pointer to a valid Graphics Context (aka Canvass).
749  \param bitmap the pointer to a valid Graphics Bitmap to be rendered.
750  \param scale_x the Scale Factor for X axis
751  \param scale_y the Scale Factor for Y axis
752  \param x the X coordinate of the top left corner of the image.
753  \param y the Y coordinate of the top left corner of the image.
754 
755  \return 0 (false) on error, any other value on success.
756 
757  \sa rl2_graph_create_bitmap, rl2_graph_destroy_bitmap,
758  rl2_graph_draw_bitmap
759  */
760     RL2_DECLARE int rl2_graph_draw_rescaled_bitmap (rl2GraphicsContextPtr
761 						    context,
762 						    rl2GraphicsBitmapPtr bitmap,
763 						    double scale_x,
764 						    double scale_y, int x,
765 						    int y);
766 
767 /**
768  Creates an RGB Array corresponding to the current Canvass
769 
770  \param context the pointer to a valid Graphics Context (aka Canvass).
771 
772  \return the pointer to the RGB Array: NULL on failure.
773 
774  \sa rl2_graph_get_context_alpha_array
775 
776  \note you are responsible to destroy (before or after) any RGB Array
777  returned by rl2_graph_get_context_rgb_array() by invoking free().
778  */
779     RL2_DECLARE unsigned char
780 	*rl2_graph_get_context_rgb_array (rl2GraphicsContextPtr context);
781 
782 /**
783  Creates an Array of Alpha values corresponding to the current Canvass
784 
785  \param context the pointer to a valid Graphics Context (aka Canvass).
786 
787  \return the pointer to the Array of Alpha Values: NULL on failure.
788 
789  \sa rl2_graph_get_context_rgb_array
790 
791  \note you are responsible to destroy (before or after) any RGB Array
792  returned by rl2_graph_get_context_alpha_array() by invoking free().
793  */
794     RL2_DECLARE unsigned char
795 	*rl2_graph_get_context_alpha_array (rl2GraphicsContextPtr context);
796 
797 #ifdef __cplusplus
798 }
799 #endif
800 
801 #endif				/* _RL2GPAPHICS_H */
802