2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = cairo-cairo-t.html
47 * - cairo_surface_t* -> Surface
52 module cairoLib
.Cairo
;
54 private import cairoLib
.cairoLibtypes
;
56 private import lib
.cairoLib
;
58 private import cairoLib
.Surface
;
59 private import glib
.Str
;
63 * cairo_t is the main object used when drawing with cairo. To
64 * draw with cairo, you create a cairo_t, set the target surface,
65 * and drawing options for the cairo_t, create shapes with
66 * functions like cairo_move_to() and cairo_line_to(), and then
67 * draw shapes with cairo_stroke() or cairo_fill().
68 * cairo_t's can be pushed to a stack via cairo_save().
69 * They may then safely be changed, without loosing the current state.
70 * Use cairo_restore() to restore to the saved state.
75 /** the main Gtk struct */
76 protected cairo_t
* cairo
;
79 public cairo_t
* getCairoStruct()
85 /** the main Gtk struct as a void* */
86 protected void* getStruct()
88 return cast(void*)cairo
;
92 * Sets our main struct and passes it to the parent class
94 public this (cairo_t
* cairo
)
113 * Creates a new cairo_t with all graphics state parameters set to
114 * default values and with target as a target surface. The target
115 * surface should be constructed with a backend-specific function such
116 * as cairo_image_surface_create() (or any other
117 * cairo_<backend>_surface_create variant).
118 * This function references target, so you can immediately
119 * call cairo_surface_destroy() on it if you don't need to
120 * maintain a separate reference to it.
122 * target surface for the context
124 * a newly allocated cairo_t with a reference
125 * count of 1. The initial reference count should be released
126 * with cairo_destroy() when you are done using the cairo_t.
127 * This function never returns NULL. If memory cannot be
128 * allocated, a special cairo_t object will be returned on
129 * which cairo_status() returns CAIRO_STATUS_NO_MEMORY.
130 * You can use this object normally, but no drawing will
133 public static Cairo
create(Surface target
)
135 // cairo_t* cairo_create (cairo_surface_t *target);
136 return new Cairo( cairo_create((target
is null) ?
null : target
.getSurfaceStruct()) );
140 * Increases the reference count on cr by one. This prevents
141 * cr from being destroyed until a matching call to cairo_destroy()
146 * the referenced cairo_t.
148 public Cairo
reference()
150 // cairo_t* cairo_reference (cairo_t *cr);
151 return new Cairo( cairo_reference(cairo
) );
155 * Decreases the reference count on cr by one. If the result
156 * is zero, then cr and all associated resources are freed.
157 * See cairo_reference().
161 public void destroy()
163 // void cairo_destroy (cairo_t *cr);
164 cairo_destroy(cairo
);
168 * Checks whether an error has previously occurred for this context.
172 * the current status of this context, see cairo_status_t
174 public cairo_status_t
status()
176 // cairo_status_t cairo_status (cairo_t *cr);
177 return cairo_status(cairo
);
181 * Makes a copy of the current state of cr and saves it
182 * on an internal stack of saved states for cr. When
183 * cairo_restore() is called, cr will be restored to
184 * the saved state. Multiple calls to cairo_save() and
185 * cairo_restore() can be nested; each call to cairo_restore()
186 * restores the state from the matching paired cairo_save().
187 * It isn't necessary to clear all saved states before
188 * a cairo_t is freed. If the reference count of a cairo_t
189 * drops to zero in response to a call to cairo_destroy(),
190 * any saved states will be freed along with the cairo_t.
196 // void cairo_save (cairo_t *cr);
201 * Restores cr to the state saved by a preceding call to
202 * cairo_save() and removes that state from the stack of
207 public void restore()
209 // void cairo_restore (cairo_t *cr);
210 cairo_restore(cairo
);
214 * Gets the target surface for the cairo context as passed to
216 * This function will always return a valid pointer, but the result
217 * can be a "nil" surface if cr is already in an error state,
218 * (ie. cairo_status() != CAIRO_STATUS_SUCCESS).
219 * A nil surface is indicated by cairo_surface_status()
220 * != CAIRO_STATUS_SUCCESS.
224 * the target surface. This object is owned by cairo. To
225 * keep a reference to it, you must call cairo_surface_reference().
227 public Surface
getTarget()
229 // cairo_surface_t* cairo_get_target (cairo_t *cr);
230 return new Surface( cairo_get_target(cairo
) );
234 * Temporarily redirects drawing to an intermediate surface known as a
235 * group. The redirection lasts until the group is completed by a call
236 * to cairo_pop_group() or cairo_pop_group_to_source(). These calls
237 * provide the result of any drawing to the group as a pattern,
238 * (either as an explicit object, or set as the source pattern).
239 * This group functionality can be convenient for performing
240 * intermediate compositing. One common use of a group is to render
241 * objects as opaque within the group, (so that they occlude each
242 * other), and then blend the result with translucence onto the
244 * Groups can be nested arbitrarily deep by making balanced calls to
245 * cairo_push_group()/cairo_pop_group(). Each call pushes/pops the new
246 * target group onto/from a stack.
247 * The cairo_push_group() function calls cairo_save() so that any
248 * changes to the graphics state will not be visible outside the
249 * group, (the pop_group functions call cairo_restore()).
250 * By default the intermediate group will have a content type of
251 * CAIRO_CONTENT_COLOR_ALPHA. Other content types can be chosen for
252 * the group by using cairo_push_group_with_content() instead.
253 * As an example, here is how one might fill and stroke a path with
254 * translucence, but without any portion of the fill being visible
256 * cairo_push_group (cr);
257 * cairo_set_source (cr, fill_pattern);
258 * cairo_fill_preserve (cr);
259 * cairo_set_source (cr, stroke_pattern);
261 * cairo_pop_group_to_source (cr);
262 * cairo_paint_with_alpha (cr, alpha);
267 public void pushGroup()
269 // void cairo_push_group (cairo_t *cr);
270 cairo_push_group(cairo
);
274 * Temporarily redirects drawing to an intermediate surface known as a
275 * group. The redirection lasts until the group is completed by a call
276 * to cairo_pop_group() or cairo_pop_group_to_source(). These calls
277 * provide the result of any drawing to the group as a pattern,
278 * (either as an explicit object, or set as the source pattern).
279 * The group will have a content type of content. The ability to
280 * control this content type is the only distinction between this
281 * function and cairo_push_group() which you should see for a more
282 * detailed description of group rendering.
286 * a cairo_content_t indicating the type of group that
290 public void pushGroupWithContent(cairo_content_t content
)
292 // void cairo_push_group_with_content (cairo_t *cr, cairo_content_t content);
293 cairo_push_group_with_content(cairo
, content
);
297 * Terminates the redirection begun by a call to cairo_push_group() or
298 * cairo_push_group_with_content() and returns a new pattern
299 * containing the results of all drawing operations performed to the
301 * The cairo_pop_group() function calls cairo_restore(), (balancing a
302 * call to cairo_save() by the push_group function), so that any
303 * changes to the graphics state will not be visible outside the
308 * a newly created (surface) pattern containing the
309 * results of all drawing operations performed to the group. The
310 * caller owns the returned object and should call
311 * cairo_pattern_destroy() when finished with it.
314 public cairo_pattern_t
* popGroup()
316 // cairo_pattern_t* cairo_pop_group (cairo_t *cr);
317 return cairo_pop_group(cairo
);
321 * Terminates the redirection begun by a call to cairo_push_group() or
322 * cairo_push_group_with_content() and installs the resulting pattern
323 * as the source pattern in the given cairo context.
324 * The behavior of this function is equivalent to the sequence of
326 * cairo_pattern_t *group = cairo_pop_group (cr);
327 * cairo_set_source (cr, group);
328 * cairo_pattern_destroy (group);
329 * but is more convenient as their is no need for a variable to store
330 * the short-lived pointer to the pattern.
331 * The cairo_pop_group() function calls cairo_restore(), (balancing a
332 * call to cairo_save() by the push_group function), so that any
333 * changes to the graphics state will not be visible outside the
339 public void popGroupToSource()
341 // void cairo_pop_group_to_source (cairo_t *cr);
342 cairo_pop_group_to_source(cairo
);
346 * Gets the target surface for the current group as started by the
347 * most recent call to cairo_push_group() or
348 * cairo_push_group_with_content().
349 * This function will return NULL if called "outside" of any group
350 * rendering blocks, (that is, after the last balancing call to
351 * cairo_pop_group() or cairo_pop_group_to_source()).
355 * the target group surface, or NULL if none. This
356 * object is owned by cairo. To keep a reference to it, you must call
357 * cairo_surface_reference().
360 public Surface
getGroupTarget()
362 // cairo_surface_t* cairo_get_group_target (cairo_t *cr);
363 return new Surface( cairo_get_group_target(cairo
) );
367 * Sets the source pattern within cr to an opaque color. This opaque
368 * color will then be used for any subsequent drawing operation until
369 * a new source pattern is set.
370 * The color components are floating point numbers in the range 0 to
371 * 1. If the values passed in are outside that range, they will be
376 * red component of color
378 * green component of color
380 * blue component of color
382 public void setSourceRgb(double red
, double green
, double blue
)
384 // void cairo_set_source_rgb (cairo_t *cr, double red, double green, double blue);
385 cairo_set_source_rgb(cairo
, red
, green
, blue
);
389 * Sets the source pattern within cr to a translucent color. This
390 * color will then be used for any subsequent drawing operation until
391 * a new source pattern is set.
392 * The color and alpha components are floating point numbers in the
393 * range 0 to 1. If the values passed in are outside that range, they
398 * red component of color
400 * green component of color
402 * blue component of color
404 * alpha component of color
406 public void setSourceRgba(double red
, double green
, double blue
, double alpha
)
408 // void cairo_set_source_rgba (cairo_t *cr, double red, double green, double blue, double alpha);
409 cairo_set_source_rgba(cairo
, red
, green
, blue
, alpha
);
413 * Sets the source pattern within cr to source. This pattern
414 * will then be used for any subsequent drawing operation until a new
415 * source pattern is set.
416 * Note: The pattern's transformation matrix will be locked to the
417 * user space in effect at the time of cairo_set_source(). This means
418 * that further modifications of the current transformation matrix
419 * will not affect the source pattern. See cairo_pattern_set_matrix().
420 * XXX: I'd also like to direct the reader's attention to some
421 * (not-yet-written) section on cairo's imaging model. How would I do
422 * that if such a section existed? (cworth).
426 * a cairo_pattern_t to be used as the source for
427 * subsequent drawing operations.
429 public void setSource(cairo_pattern_t
* source
)
431 // void cairo_set_source (cairo_t *cr, cairo_pattern_t *source);
432 cairo_set_source(cairo
, source
);
436 * This is a convenience function for creating a pattern from surface
437 * and setting it as the source in cr with cairo_set_source().
438 * The x and y parameters give the user-space coordinate at which
439 * the surface origin should appear. (The surface origin is its
440 * upper-left corner before any transformation has been applied.) The
441 * x and y patterns are negated and then set as translation values
442 * in the pattern matrix.
443 * Other than the initial translation pattern matrix, as described
444 * above, all other pattern attributes, (such as its extend mode), are
445 * set to the default values as in cairo_pattern_create_for_surface().
446 * The resulting pattern can be queried with cairo_get_source() so
447 * that these attributes can be modified if desired, (eg. to create a
448 * repeating pattern with cairo_pattern_set_extend()).
452 * a surface to be used to set the source pattern
454 * User-space X coordinate for surface origin
456 * User-space Y coordinate for surface origin
458 public void setSourceSurface(Surface surface
, double x
, double y
)
460 // void cairo_set_source_surface (cairo_t *cr, cairo_surface_t *surface, double x, double y);
461 cairo_set_source_surface(cairo
, (surface
is null) ?
null : surface
.getSurfaceStruct(), x
, y
);
465 * Gets the current source pattern for cr.
469 * the current source pattern. This object is owned by
470 * cairo. To keep a reference to it, you must call
471 * cairo_pattern_reference().
473 public cairo_pattern_t
* getSource()
475 // cairo_pattern_t* cairo_get_source (cairo_t *cr);
476 return cairo_get_source(cairo
);
481 * Set the antialiasing mode of the rasterizer used for drawing shapes.
482 * This value is a hint, and a particular backend may or may not support
483 * a particular value. At the current time, no backend supports
484 * CAIRO_ANTIALIAS_SUBPIXEL when drawing shapes.
485 * Note that this option does not affect text rendering, instead see
486 * cairo_font_options_set_antialias().
490 * the new antialiasing mode
492 public void setAntialias(cairo_antialias_t antialias
)
494 // void cairo_set_antialias (cairo_t *cr, cairo_antialias_t antialias);
495 cairo_set_antialias(cairo
, antialias
);
499 * Gets the current shape antialiasing mode, as set by cairo_set_shape_antialias().
503 * the current shape antialiasing mode.
505 public cairo_antialias_t
getAntialias()
507 // cairo_antialias_t cairo_get_antialias (cairo_t *cr);
508 return cairo_get_antialias(cairo
);
512 * Sets the dash pattern to be used by cairo_stroke(). A dash pattern
513 * is specified by dashes, an array of positive values. Each value
514 * provides the length of alternate "on" and "off" portions of the
515 * stroke. The offset specifies an offset into the pattern at which
517 * Each "on" segment will have caps applied as if the segment were a
518 * separate sub-path. In particular, it is valid to use an "on" length
519 * of 0.0 with CAIRO_LINE_CAP_ROUND or CAIRO_LINE_CAP_SQUARE in order
520 * to distributed dots or squares along a path.
521 * Note: The length values are in user-space units as evaluated at the
522 * time of stroking. This is not necessarily the same as the user
523 * space at the time of cairo_set_dash().
524 * If num_dashes is 0 dashing is disabled.
525 * If num_dashes is 1 a symmetric pattern is assumed with alternating
526 * on and off portions of the size specified by the single value in
528 * If any value in dashes is negative, or if all values are 0, then
529 * cairo_t will be put into an error state with a status of
530 * CAIRO_STATUS_INVALID_DASH.
534 * an array specifying alternate lengths of on and off stroke portions
536 * the length of the dashes array
538 * an offset into the dash pattern at which the stroke should start
540 public void setDash(double* dashes
, int numDashes
, double offset
)
542 // void cairo_set_dash (cairo_t *cr, const double *dashes, int num_dashes, double offset);
543 cairo_set_dash(cairo
, dashes
, numDashes
, offset
);
548 * Set the current fill rule within the cairo context. The fill rule
549 * is used to determine which regions are inside or outside a complex
550 * (potentially self-intersecting) path. The current fill rule affects
551 * both cairo_fill and cairo_clip. See cairo_fill_rule_t for details
552 * on the semantics of each available fill rule.
556 * a fill rule, specified as a cairo_fill_rule_t
558 public void setFillRule(cairo_fill_rule_t fillRule
)
560 // void cairo_set_fill_rule (cairo_t *cr, cairo_fill_rule_t fill_rule);
561 cairo_set_fill_rule(cairo
, fillRule
);
565 * Gets the current fill rule, as set by cairo_set_fill_rule().
569 * the current fill rule.
571 public cairo_fill_rule_t
getFillRule()
573 // cairo_fill_rule_t cairo_get_fill_rule (cairo_t *cr);
574 return cairo_get_fill_rule(cairo
);
579 * Sets the current line cap style within the cairo context. See
580 * cairo_line_cap_t for details about how the available line cap
582 * As with the other stroke parameters, the current line cap style is
583 * examined by cairo_stroke(), cairo_stroke_extents(), and
584 * cairo_stroke_to_path(), but does not have any effect during path
587 * a cairo context, as a cairo_t
589 * a line cap style, as a cairo_line_cap_t
591 public void setLineCap(cairo_line_cap_t lineCap
)
593 // void cairo_set_line_cap (cairo_t *cr, cairo_line_cap_t line_cap);
594 cairo_set_line_cap(cairo
, lineCap
);
598 * Gets the current line cap style, as set by cairo_set_line_cap().
602 * the current line cap style.
604 public cairo_line_cap_t
getLineCap()
606 // cairo_line_cap_t cairo_get_line_cap (cairo_t *cr);
607 return cairo_get_line_cap(cairo
);
612 * Sets the current line join style within the cairo context. See
613 * cairo_line_join_t for details about how the available line join
615 * As with the other stroke parameters, the current line join style is
616 * examined by cairo_stroke(), cairo_stroke_extents(), and
617 * cairo_stroke_to_path(), but does not have any effect during path
620 * a cairo context, as a cairo_t
622 * a line joint style, as a cairo_line_join_t
624 public void setLineJoin(cairo_line_join_t lineJoin
)
626 // void cairo_set_line_join (cairo_t *cr, cairo_line_join_t line_join);
627 cairo_set_line_join(cairo
, lineJoin
);
631 * Gets the current line join style, as set by cairo_set_line_join().
635 * the current line join style.
637 public cairo_line_join_t
getLineJoin()
639 // cairo_line_join_t cairo_get_line_join (cairo_t *cr);
640 return cairo_get_line_join(cairo
);
644 * Sets the current line width within the cairo context. The line
645 * width value specifies the diameter of a pen that is circular in
646 * user space, (though device-space pen may be an ellipse in general
647 * due to scaling/shear/rotation of the CTM).
648 * Note: When the description above refers to user space and CTM it
649 * refers to the user space and CTM in effect at the time of the
650 * stroking operation, not the user space and CTM in effect at the
651 * time of the call to cairo_set_line_width(). The simplest usage
652 * makes both of these spaces identical. That is, if there is no
653 * change to the CTM between a call to cairo_set_line_with() and the
654 * stroking operation, then one can just pass user-space values to
655 * cairo_set_line_width() and ignore this note.
656 * As with the other stroke parameters, the current line width is
657 * examined by cairo_stroke(), cairo_stroke_extents(), and
658 * cairo_stroke_to_path(), but does not have any effect during path
660 * The default line width value is 2.0.
666 public void setLineWidth(double width
)
668 // void cairo_set_line_width (cairo_t *cr, double width);
669 cairo_set_line_width(cairo
, width
);
676 * the current line width value exactly as set by
677 * cairo_set_line_width(). Note that the value is unchanged even if
678 * the CTM has changed between the calls to cairo_set_line_width() and
679 * cairo_get_line_width().
681 public double getLineWidth()
683 // double cairo_get_line_width (cairo_t *cr);
684 return cairo_get_line_width(cairo
);
691 public void setMiterLimit(double limit
)
693 // void cairo_set_miter_limit (cairo_t *cr, double limit);
694 cairo_set_miter_limit(cairo
, limit
);
698 * Gets the current miter limit, as set by cairo_set_miter_limit().
702 * the current miter limit.
704 public double getMiterLimit()
706 // double cairo_get_miter_limit (cairo_t *cr);
707 return cairo_get_miter_limit(cairo
);
712 * Sets the compositing operator to be used for all drawing
713 * operations. See cairo_operator_t for details on the semantics of
714 * each available compositing operator.
715 * XXX: I'd also like to direct the reader's attention to some
716 * (not-yet-written) section on cairo's imaging model. How would I do
717 * that if such a section existed? (cworth).
721 * a compositing operator, specified as a cairo_operator_t
723 public void setOperator(cairo_operator_t op
)
725 // void cairo_set_operator (cairo_t *cr, cairo_operator_t op);
726 cairo_set_operator(cairo
, op
);
730 * Gets the current compositing operator for a cairo context.
734 * the current compositing operator.
736 public cairo_operator_t
getOperator()
738 // cairo_operator_t cairo_get_operator (cairo_t *cr);
739 return cairo_get_operator(cairo
);
743 * Sets the tolerance used when converting paths into trapezoids.
744 * Curved segments of the path will be subdivided until the maximum
745 * deviation between the original path and the polygonal approximation
746 * is less than tolerance. The default value is 0.1. A larger
747 * value will give better performance, a smaller value, better
748 * appearance. (Reducing the value from the default value of 0.1
749 * is unlikely to improve appearance significantly.)
753 * the tolerance, in device units (typically pixels)
755 public void setTolerance(double tolerance
)
757 // void cairo_set_tolerance (cairo_t *cr, double tolerance);
758 cairo_set_tolerance(cairo
, tolerance
);
762 * Gets the current tolerance value, as set by cairo_set_tolerance().
766 * the current tolerance value.
768 public double getTolerance()
770 // double cairo_get_tolerance (cairo_t *cr);
771 return cairo_get_tolerance(cairo
);
775 * Establishes a new clip region by intersecting the current clip
776 * region with the current path as it would be filled by cairo_fill()
777 * and according to the current fill rule (see cairo_set_fill_rule()).
778 * After cairo_clip, the current path will be cleared from the cairo
780 * The current clip region affects all drawing operations by
781 * effectively masking out any changes to the surface that are outside
782 * the current clip region.
783 * Calling cairo_clip() can only make the clip region smaller, never
784 * larger. But the current clip is part of the graphics state, so a
785 * temporary restriction of the clip region can be achieved by
786 * calling cairo_clip() within a cairo_save()/cairo_restore()
787 * pair. The only other means of increasing the size of the clip
788 * region is cairo_reset_clip().
794 // void cairo_clip (cairo_t *cr);
799 * Establishes a new clip region by intersecting the current clip
800 * region with the current path as it would be filled by cairo_fill()
801 * and according to the current fill rule (see cairo_set_fill_rule()).
802 * Unlike cairo_clip(), cairo_clip_preserve preserves the path within
804 * The current clip region affects all drawing operations by
805 * effectively masking out any changes to the surface that are outside
806 * the current clip region.
807 * Calling cairo_clip() can only make the clip region smaller, never
808 * larger. But the current clip is part of the graphics state, so a
809 * temporary restriction of the clip region can be achieved by
810 * calling cairo_clip() within a cairo_save()/cairo_restore()
811 * pair. The only other means of increasing the size of the clip
812 * region is cairo_reset_clip().
816 public void clipPreserve()
818 // void cairo_clip_preserve (cairo_t *cr);
819 cairo_clip_preserve(cairo
);
823 * Reset the current clip region to its original, unrestricted
824 * state. That is, set the clip region to an infinitely large shape
825 * containing the target surface. Equivalently, if infinity is too
826 * hard to grasp, one can imagine the clip region being reset to the
827 * exact bounds of the target surface.
828 * Note that code meant to be reusable should not call
829 * cairo_reset_clip() as it will cause results unexpected by
830 * higher-level code which calls cairo_clip(). Consider using
831 * cairo_save() and cairo_restore() around cairo_clip() as a more
832 * robust means of temporarily restricting the clip region.
836 public void resetClip()
838 // void cairo_reset_clip (cairo_t *cr);
839 cairo_reset_clip(cairo
);
843 * A drawing operator that fills the current path according to the
844 * current fill rule, (each sub-path is implicitly closed before being
845 * filled). After cairo_fill, the current path will be cleared from
846 * the cairo context. See cairo_set_fill_rule() and
847 * cairo_fill_preserve().
853 // void cairo_fill (cairo_t *cr);
858 * A drawing operator that fills the current path according to the
859 * current fill rule, (each sub-path is implicitly closed before being
860 * filled). Unlike cairo_fill(), cairo_fill_preserve preserves the
861 * path within the cairo context.
862 * See cairo_set_fill_rule() and cairo_fill().
866 public void fillPreserve()
868 // void cairo_fill_preserve (cairo_t *cr);
869 cairo_fill_preserve(cairo
);
879 public void fillExtents(double* x1
, double* y1
, double* x2
, double* y2
)
881 // void cairo_fill_extents (cairo_t *cr, double *x1, double *y1, double *x2, double *y2);
882 cairo_fill_extents(cairo
, x1
, y1
, x2
, y2
);
886 * Tests whether the given point is on the area filled by doing a
887 * cairo_stroke() operation on cr given the current path and filling
889 * See cairo_fill(), cairo_set_fill_rule() and cairo_fill_preserve().
893 * X coordinate of the point to test
895 * Y coordinate of the point to test
898 public cairo_bool_t
inFill(double x
, double y
)
900 // cairo_bool_t cairo_in_fill (cairo_t *cr, double x, double y);
901 return cairo_in_fill(cairo
, x
, y
);
905 * A drawing operator that paints the current source
906 * using the alpha channel of pattern as a mask. (Opaque
907 * areas of pattern are painted with the source, transparent
908 * areas are not painted.)
914 public void mask(cairo_pattern_t
* pattern
)
916 // void cairo_mask (cairo_t *cr, cairo_pattern_t *pattern);
917 cairo_mask(cairo
, pattern
);
921 * A drawing operator that paints the current source
922 * using the alpha channel of surface as a mask. (Opaque
923 * areas of surface are painted with the source, transparent
924 * areas are not painted.)
930 * X coordinate at which to place the origin of surface
932 * Y coordinate at which to place the origin of surface
934 public void maskSurface(Surface surface
, double surfaceX
, double surfaceY
)
936 // void cairo_mask_surface (cairo_t *cr, cairo_surface_t *surface, double surface_x, double surface_y);
937 cairo_mask_surface(cairo
, (surface
is null) ?
null : surface
.getSurfaceStruct(), surfaceX
, surfaceY
);
941 * A drawing operator that paints the current source everywhere within
942 * the current clip region.
948 // void cairo_paint (cairo_t *cr);
953 * A drawing operator that paints the current source everywhere within
954 * the current clip region using a mask of constant alpha value
955 * alpha. The effect is similar to cairo_paint(), but the drawing
956 * is faded out using the alpha value.
960 * alpha value, between 0 (transparent) and 1 (opaque)
962 public void paintWithAlpha(double alpha
)
964 // void cairo_paint_with_alpha (cairo_t *cr, double alpha);
965 cairo_paint_with_alpha(cairo
, alpha
);
969 * A drawing operator that strokes the current path according to the
970 * current line width, line join, line cap, and dash settings. After
971 * cairo_stroke, the current path will be cleared from the cairo
972 * context. See cairo_set_line_width(), cairo_set_line_join(),
973 * cairo_set_line_cap(), cairo_set_dash(), and
974 * cairo_stroke_preserve().
975 * Note: Degenerate segments and sub-paths are treated specially and
976 * provide a useful result. These can result in two different
978 * 1. Zero-length "on" segments set in cairo_set_dash(). If the cap
979 * style is CAIRO_LINE_CAP_ROUND or CAIRO_LINE_CAP_SQUARE then these
980 * segments will be drawn as circular dots or squares respectively. In
981 * the case of CAIRO_LINE_CAP_SQUARE, the orientation of the squares
982 * is determined by the direction of the underlying path.
983 * 2. A sub-path created by cairo_move_to() followed by either a
984 * cairo_close_path() or one or more calls to cairo_line_to() to the
985 * same coordinate as the cairo_move_to(). If the cap style is
986 * CAIRO_LINE_CAP_ROUND then these sub-paths will be drawn as circular
987 * dots. Note that in the case of CAIRO_LINE_CAP_SQUARE a degenerate
988 * sub-path will not be drawn at all, (since the correct orientation
990 * In no case will a cap style of CAIRO_LINE_CAP_BUTT cause anything
991 * to be drawn in the case of either degenerate segments or sub-paths.
997 // void cairo_stroke (cairo_t *cr);
1002 * A drawing operator that strokes the current path according to the
1003 * current line width, line join, line cap, and dash settings. Unlike
1004 * cairo_stroke(), cairo_stroke_preserve preserves the path within the
1006 * See cairo_set_line_width(), cairo_set_line_join(),
1007 * cairo_set_line_cap(), cairo_set_dash(), and
1008 * cairo_stroke_preserve().
1012 public void strokePreserve()
1014 // void cairo_stroke_preserve (cairo_t *cr);
1015 cairo_stroke_preserve(cairo
);
1025 public void strokeExtents(double* x1
, double* y1
, double* x2
, double* y2
)
1027 // void cairo_stroke_extents (cairo_t *cr, double *x1, double *y1, double *x2, double *y2);
1028 cairo_stroke_extents(cairo
, x1
, y1
, x2
, y2
);
1032 * Tests whether the given point is on the area stroked by doing a
1033 * cairo_stroke() operation on cr given the current path and stroking
1035 * See cairo_stroke, cairo_set_line_width(), cairo_set_line_join(),
1036 * cairo_set_line_cap(), cairo_set_dash(), and
1037 * cairo_stroke_preserve().
1041 * X coordinate of the point to test
1043 * Y coordinate of the point to test
1046 public cairo_bool_t
inStroke(double x
, double y
)
1048 // cairo_bool_t cairo_in_stroke (cairo_t *cr, double x, double y);
1049 return cairo_in_stroke(cairo
, x
, y
);
1053 * Emits the current page for backends that support multiple pages, but
1054 * doesn't clear it, so, the contents of the current page will be retained
1055 * for the next page too. Use cairo_show_page() if you want to get an
1056 * empty page after the emission.
1060 public void copyPage()
1062 // void cairo_copy_page (cairo_t *cr);
1063 cairo_copy_page(cairo
);
1067 * Emits and clears the current page for backends that support multiple
1068 * pages. Use cairo_copy_page() if you don't want to clear the page.
1072 public void showPage()
1074 // void cairo_show_page (cairo_t *cr);
1075 cairo_show_page(cairo
);
1082 * Creates a copy of the current path and returns it to the user as a
1083 * cairo_path_t. See cairo_path_data_t for hints on how to iterate
1084 * over the returned data structure.
1085 * This function will always return a valid pointer, but the result
1086 * will have no data (data==NULL and
1087 * num_data==0), if either of the following
1089 * If there is insufficient memory to copy the path.
1090 * If cr is already in an error state.
1091 * In either case, path->status will be set to
1092 * CAIRO_STATUS_NO_MEMORY (regardless of what the error status in
1093 * cr might have been).
1097 * the copy of the current path. The caller owns the
1098 * returned object and should call cairo_path_destroy() when finished
1101 public cairo_path_t
* copyPath()
1103 // cairo_path_t* cairo_copy_path (cairo_t *cr);
1104 return cairo_copy_path(cairo
);
1108 * Gets a flattened copy of the current path and returns it to the
1109 * user as a cairo_path_t. See cairo_path_data_t for hints on
1110 * how to iterate over the returned data structure.
1111 * This function is like cairo_copy_path() except that any curves
1112 * in the path will be approximated with piecewise-linear
1113 * approximations, (accurate to within the current tolerance
1114 * value). That is, the result is guaranteed to not have any elements
1115 * of type CAIRO_PATH_CURVE_TO which will instead be replaced by a
1116 * series of CAIRO_PATH_LINE_TO elements.
1117 * This function will always return a valid pointer, but the result
1118 * will have no data (data==NULL and
1119 * num_data==0), if either of the following
1121 * If there is insufficient memory to copy the path. In this
1122 * case path->status will be set to
1123 * CAIRO_STATUS_NO_MEMORY.
1124 * If cr is already in an error state. In this case
1125 * path->status will contain the same status that
1126 * would be returned by cairo_status().
1130 * the copy of the current path. The caller owns the
1131 * returned object and should call cairo_path_destroy() when finished
1134 public cairo_path_t
* copyPathFlat()
1136 // cairo_path_t* cairo_copy_path_flat (cairo_t *cr);
1137 return cairo_copy_path_flat(cairo
);
1141 * Immediately releases all memory associated with path. After a call
1142 * to cairo_path_destroy() the path pointer is no longer valid and
1143 * should not be used further.
1144 * NOTE: cairo_path_destroy function should only be called with a
1145 * pointer to a cairo_path_t returned by a cairo function. Any path
1146 * that is created manually (ie. outside of cairo) should be destroyed
1149 * a path previously returned by either cairo_copy_path() or
1150 * cairo_copy_path_flat().
1152 public static void pathDestroy(cairo_path_t
* path
)
1154 // void cairo_path_destroy (cairo_path_t *path);
1155 cairo_path_destroy(path
);
1159 * Append the path onto the current path. The path may be either the
1160 * return value from one of cairo_copy_path() or
1161 * cairo_copy_path_flat() or it may be constructed manually. See
1162 * cairo_path_t for details on how the path data structure should be
1163 * initialized, and note that path->status must be
1164 * initialized to CAIRO_STATUS_SUCCESS.
1168 * path to be appended
1170 public void appendPath(cairo_path_t
* path
)
1172 // void cairo_append_path (cairo_t *cr, cairo_path_t *path);
1173 cairo_append_path(cairo
, path
);
1177 * Gets the current point of the current path, which is
1178 * conceptually the final point reached by the path so far.
1179 * The current point is returned in the user-space coordinate
1180 * system. If there is no defined current point then x and y will
1181 * both be set to 0.0.
1182 * Most path construction functions alter the current point. See the
1183 * following for details on how they affect the current point:
1184 * cairo_new_path(), cairo_move_to(), cairo_line_to(),
1185 * cairo_curve_to(), cairo_arc(), cairo_rel_move_to(),
1186 * cairo_rel_line_to(), cairo_rel_curve_to(), cairo_arc(),
1187 * cairo_text_path(), cairo_stroke_to_path()
1191 * return value for X coordinate of the current point
1193 * return value for Y coordinate of the current point
1195 public void getCurrentPoint(double* x
, double* y
)
1197 // void cairo_get_current_point (cairo_t *cr, double *x, double *y);
1198 cairo_get_current_point(cairo
, x
, y
);
1202 * Clears the current path. After this call there will be no path and
1207 public void newPath()
1209 // void cairo_new_path (cairo_t *cr);
1210 cairo_new_path(cairo
);
1214 * Begin a new sub-path. Note that the existing path is not
1215 * affected. After this call there will be no current point.
1216 * In many cases, this call is not needed since new sub-paths are
1217 * frequently started with cairo_move_to().
1218 * A call to cairo_new_sub_path() is particularly useful when
1219 * beginning a new sub-path with one of the cairo_arc() calls. This
1220 * makes things easier as it is no longer necessary to manually
1221 * compute the arc's initial coordinates for a call to
1227 public void newSubPath()
1229 // void cairo_new_sub_path (cairo_t *cr);
1230 cairo_new_sub_path(cairo
);
1234 * Adds a line segment to the path from the current point to the
1235 * beginning of the current sub-path, (the most recent point passed to
1236 * cairo_move_to()), and closes this sub-path. After this call the
1237 * current point will be at the joined endpoint of the sub-path.
1238 * The behavior of cairo_close_path() is distinct from simply calling
1239 * cairo_line_to() with the equivalent coordinate in the case of
1240 * stroking. When a closed sub-path is stroked, there are no caps on
1241 * the ends of the sub-path. Instead, there is a line join connecting
1242 * the final and initial segments of the sub-path.
1243 * If there is no current point before the call to cairo_close_path,
1244 * this function will have no effect.
1245 * Note: As of cairo version 1.2.4 any call to cairo_close_path will
1246 * place an explicit MOVE_TO element into the path immediately after
1247 * the CLOSE_PATH element, (which can be seen in cairo_copy_path() for
1248 * example). This can simplify path processing in some cases as it may
1249 * not be necessary to save the "last move_to point" during processing
1250 * as the MOVE_TO immediately after the CLOSE_PATH will provide that
1255 public void closePath()
1257 // void cairo_close_path (cairo_t *cr);
1258 cairo_close_path(cairo
);
1262 * Adds a circular arc of the given radius to the current path. The
1263 * arc is centered at (xc, yc), begins at angle1 and proceeds in
1264 * the direction of increasing angles to end at angle2. If angle2 is
1265 * less than angle1 it will be progressively increased by 2*M_PI
1266 * until it is greater than angle1.
1267 * If there is a current point, an initial line segment will be added
1268 * to the path to connect the current point to the beginning of the
1270 * Angles are measured in radians. An angle of 0.0 is in the direction
1271 * of the positive X axis (in user space). An angle of M_PI/2.0 radians
1272 * (90 degrees) is in the direction of the positive Y axis (in
1273 * user space). Angles increase in the direction from the positive X
1274 * axis toward the positive Y axis. So with the default transformation
1275 * matrix, angles increase in a clockwise direction.
1276 * (To convert from degrees to radians, use degrees * (M_PI /
1278 * This function gives the arc in the direction of increasing angles;
1279 * see cairo_arc_negative() to get the arc in the direction of
1280 * decreasing angles.
1281 * The arc is circular in user space. To achieve an elliptical arc,
1282 * you can scale the current transformation matrix by different
1283 * amounts in the X and Y directions. For example, to draw an ellipse
1284 * in the box given by x, y, width, height:
1286 * cairo_translate (cr, x + width / 2., y + height / 2.);
1287 * cairo_scale (cr, 1. / (height / 2.), 1. / (width / 2.));
1288 * cairo_arc (cr, 0., 0., 1., 0., 2 * M_PI);
1289 * cairo_restore (cr);
1293 * X position of the center of the arc
1295 * Y position of the center of the arc
1297 * the radius of the arc
1299 * the start angle, in radians
1301 * the end angle, in radians
1303 public void arc(double xc
, double yc
, double radius
, double angle1
, double angle2
)
1305 // void cairo_arc (cairo_t *cr, double xc, double yc, double radius, double angle1, double angle2);
1306 cairo_arc(cairo
, xc
, yc
, radius
, angle1
, angle2
);
1310 * Adds a circular arc of the given radius to the current path. The
1311 * arc is centered at (xc, yc), begins at angle1 and proceeds in
1312 * the direction of decreasing angles to end at angle2. If angle2 is
1313 * greater than angle1 it will be progressively decreased by 2*M_PI
1314 * until it is greater than angle1.
1315 * See cairo_arc() for more details. This function differs only in the
1316 * direction of the arc between the two angles.
1320 * X position of the center of the arc
1322 * Y position of the center of the arc
1324 * the radius of the arc
1326 * the start angle, in radians
1328 * the end angle, in radians
1330 public void arcNegative(double xc
, double yc
, double radius
, double angle1
, double angle2
)
1332 // void cairo_arc_negative (cairo_t *cr, double xc, double yc, double radius, double angle1, double angle2);
1333 cairo_arc_negative(cairo
, xc
, yc
, radius
, angle1
, angle2
);
1337 * Adds a cubic Bzier spline to the path from the current point to
1338 * position (x3, y3) in user-space coordinates, using (x1, y1) and
1339 * (x2, y2) as the control points. After this call the current point
1341 * If there is no current point before the call to cairo_curve_to()
1342 * this function will behave as if preceded by a call to
1343 * cairo_move_to (cr, x1, y1).
1347 * the X coordinate of the first control point
1349 * the Y coordinate of the first control point
1351 * the X coordinate of the second control point
1353 * the Y coordinate of the second control point
1355 * the X coordinate of the end of the curve
1357 * the Y coordinate of the end of the curve
1359 public void curveTo(double x1
, double y1
, double x2
, double y2
, double x3
, double y3
)
1361 // void cairo_curve_to (cairo_t *cr, double x1, double y1, double x2, double y2, double x3, double y3);
1362 cairo_curve_to(cairo
, x1
, y1
, x2
, y2
, x3
, y3
);
1366 * Adds a line to the path from the current point to position (x, y)
1367 * in user-space coordinates. After this call the current point
1369 * If there is no current point before the call to cairo_line_to()
1370 * this function will behave as cairo_move_to (cr, x, y).
1374 * the X coordinate of the end of the new line
1376 * the Y coordinate of the end of the new line
1378 public void lineTo(double x
, double y
)
1380 // void cairo_line_to (cairo_t *cr, double x, double y);
1381 cairo_line_to(cairo
, x
, y
);
1385 * Begin a new sub-path. After this call the current point will be (x,
1390 * the X coordinate of the new position
1392 * the Y coordinate of the new position
1394 public void moveTo(double x
, double y
)
1396 // void cairo_move_to (cairo_t *cr, double x, double y);
1397 cairo_move_to(cairo
, x
, y
);
1401 * Adds a closed sub-path rectangle of the given size to the current
1402 * path at position (x, y) in user-space coordinates.
1403 * This function is logically equivalent to:
1404 * cairo_move_to (cr, x, y);
1405 * cairo_rel_line_to (cr, width, 0);
1406 * cairo_rel_line_to (cr, 0, height);
1407 * cairo_rel_line_to (cr, -width, 0);
1408 * cairo_close_path (cr);
1412 * the X coordinate of the top left corner of the rectangle
1414 * the Y coordinate to the top left corner of the rectangle
1416 * the width of the rectangle
1418 * the height of the rectangle
1420 public void rectangle(double x
, double y
, double width
, double height
)
1422 // void cairo_rectangle (cairo_t *cr, double x, double y, double width, double height);
1423 cairo_rectangle(cairo
, x
, y
, width
, height
);
1431 public void glyphPath(cairo_glyph_t
* glyphs
, int numGlyphs
)
1433 // void cairo_glyph_path (cairo_t *cr, cairo_glyph_t *glyphs, int num_glyphs);
1434 cairo_glyph_path(cairo
, glyphs
, numGlyphs
);
1441 public void textPath(char[] utf8
)
1443 // void cairo_text_path (cairo_t *cr, const char *utf8);
1444 cairo_text_path(cairo
, Str
.toStringz(utf8
));
1448 * Relative-coordinate version of cairo_curve_to(). All offsets are
1449 * relative to the current point. Adds a cubic Bzier spline to the
1450 * path from the current point to a point offset from the current
1451 * point by (dx3, dy3), using points offset by (dx1, dy1) and
1452 * (dx2, dy2) as the control points. After this call the current
1453 * point will be offset by (dx3, dy3).
1454 * Given a current point of (x, y), cairo_rel_curve_to (cr, dx1,
1455 * dy1, dx2, dy2, dx3, dy3) is logically equivalent to
1456 * cairo_curve_to (cr, x + dx1, y + dy1, x + dx2, y + dy2, x +
1458 * It is an error to call this function with no current point. Doing
1459 * so will cause cr to shutdown with a status of
1460 * CAIRO_STATUS_NO_CURRENT_POINT.
1464 * the X offset to the first control point
1466 * the Y offset to the first control point
1468 * the X offset to the second control point
1470 * the Y offset to the second control point
1472 * the X offset to the end of the curve
1474 * the Y offset to the end of the curve
1476 public void relCurveTo(double dx1
, double dy1
, double dx2
, double dy2
, double dx3
, double dy3
)
1478 // void cairo_rel_curve_to (cairo_t *cr, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3);
1479 cairo_rel_curve_to(cairo
, dx1
, dy1
, dx2
, dy2
, dx3
, dy3
);
1483 * Relative-coordinate version of cairo_line_to(). Adds a line to the
1484 * path from the current point to a point that is offset from the
1485 * current point by (dx, dy) in user space. After this call the
1486 * current point will be offset by (dx, dy).
1487 * Given a current point of (x, y), cairo_rel_line_to(cr, dx, dy)
1488 * is logically equivalent to cairo_line_to (cr, x + dx, y + dy).
1489 * It is an error to call this function with no current point. Doing
1490 * so will cause cr to shutdown with a status of
1491 * CAIRO_STATUS_NO_CURRENT_POINT.
1495 * the X offset to the end of the new line
1497 * the Y offset to the end of the new line
1499 public void relLineTo(double dx
, double dy
)
1501 // void cairo_rel_line_to (cairo_t *cr, double dx, double dy);
1502 cairo_rel_line_to(cairo
, dx
, dy
);
1506 * Begin a new sub-path. After this call the current point will offset
1508 * Given a current point of (x, y), cairo_rel_move_to(cr, dx, dy)
1509 * is logically equivalent to cairo_move_to (cr, x + dx, y + dy).
1510 * It is an error to call this function with no current point. Doing
1511 * so will cause cr to shutdown with a status of
1512 * CAIRO_STATUS_NO_CURRENT_POINT.
1520 public void relMoveTo(double dx
, double dy
)
1522 // void cairo_rel_move_to (cairo_t *cr, double dx, double dy);
1523 cairo_rel_move_to(cairo
, dx
, dy
);
1527 * Modifies the current transformation matrix (CTM) by translating the
1528 * user-space origin by (tx, ty). This offset is interpreted as a
1529 * user-space coordinate according to the CTM in place before the new
1530 * call to cairo_translate. In other words, the translation of the
1531 * user-space origin takes place after any existing transformation.
1535 * amount to translate in the X direction
1537 * amount to translate in the Y direction
1539 public void translate(double tx
, double ty
)
1541 // void cairo_translate (cairo_t *cr, double tx, double ty);
1542 cairo_translate(cairo
, tx
, ty
);
1546 * Modifies the current transformation matrix (CTM) by scaling the X
1547 * and Y user-space axes by sx and sy respectively. The scaling of
1548 * the axes takes place after any existing transformation of user
1553 * scale factor for the X dimension
1555 * scale factor for the Y dimension
1557 public void scale(double sx
, double sy
)
1559 // void cairo_scale (cairo_t *cr, double sx, double sy);
1560 cairo_scale(cairo
, sx
, sy
);
1564 * Modifies the current transformation matrix (CTM) by rotating the
1565 * user-space axes by angle radians. The rotation of the axes takes
1566 * places after any existing transformation of user space. The
1567 * rotation direction for positive angles is from the positive X axis
1568 * toward the positive Y axis.
1572 * angle (in radians) by which the user-space axes will be
1575 public void rotate(double angle
)
1577 // void cairo_rotate (cairo_t *cr, double angle);
1578 cairo_rotate(cairo
, angle
);
1582 * Modifies the current transformation matrix (CTM) by applying
1583 * matrix as an additional transformation. The new transformation of
1584 * user space takes place after any existing transformation.
1588 * a transformation to be applied to the user-space axes
1590 public void transform(cairo_matrix_t
* matrix
)
1592 // void cairo_transform (cairo_t *cr, const cairo_matrix_t *matrix);
1593 cairo_transform(cairo
, matrix
);
1597 * Modifies the current transformation matrix (CTM) by setting it
1602 * a transformation matrix from user space to device space
1604 public void setMatrix(cairo_matrix_t
* matrix
)
1606 // void cairo_set_matrix (cairo_t *cr, const cairo_matrix_t *matrix);
1607 cairo_set_matrix(cairo
, matrix
);
1611 * Stores the current transformation matrix (CTM) into matrix.
1615 * return value for the matrix
1617 public void getMatrix(cairo_matrix_t
* matrix
)
1619 // void cairo_get_matrix (cairo_t *cr, cairo_matrix_t *matrix);
1620 cairo_get_matrix(cairo
, matrix
);
1624 * Resets the current transformation matrix (CTM) by setting it equal
1625 * to the identity matrix. That is, the user-space and device-space
1626 * axes will be aligned and one user-space unit will transform to one
1627 * device-space unit.
1631 public void identityMatrix()
1633 // void cairo_identity_matrix (cairo_t *cr);
1634 cairo_identity_matrix(cairo
);
1638 * Transform a coordinate from user space to device space by
1639 * multiplying the given point by the current transformation matrix
1644 * X value of coordinate (in/out parameter)
1646 * Y value of coordinate (in/out parameter)
1648 public void userToDevice(double* x
, double* y
)
1650 // void cairo_user_to_device (cairo_t *cr, double *x, double *y);
1651 cairo_user_to_device(cairo
, x
, y
);
1655 * Transform a distance vector from user space to device space. This
1656 * function is similar to cairo_user_to_device() except that the
1657 * translation components of the CTM will be ignored when transforming
1662 * X component of a distance vector (in/out parameter)
1664 * Y component of a distance vector (in/out parameter)
1666 public void userToDeviceDistance(double* dx
, double* dy
)
1668 // void cairo_user_to_device_distance (cairo_t *cr, double *dx, double *dy);
1669 cairo_user_to_device_distance(cairo
, dx
, dy
);
1673 * Transform a coordinate from device space to user space by
1674 * multiplying the given point by the inverse of the current
1675 * transformation matrix (CTM).
1679 * X value of coordinate (in/out parameter)
1681 * Y value of coordinate (in/out parameter)
1683 public void deviceToUser(double* x
, double* y
)
1685 // void cairo_device_to_user (cairo_t *cr, double *x, double *y);
1686 cairo_device_to_user(cairo
, x
, y
);
1690 * Transform a distance vector from device space to user space. This
1691 * function is similar to cairo_device_to_user() except that the
1692 * translation components of the inverse CTM will be ignored when
1693 * transforming (dx,dy).
1697 * X component of a distance vector (in/out parameter)
1699 * Y component of a distance vector (in/out parameter)
1701 public void deviceToUserDistance(double* dx
, double* dy
)
1703 // void cairo_device_to_user_distance (cairo_t *cr, double *dx, double *dy);
1704 cairo_device_to_user_distance(cairo
, dx
, dy
);
1711 * Selects a family and style of font from a simplified description as
1712 * a family name, slant and weight. This function is meant to be used
1713 * only for applications with simple font needs: Cairo doesn't provide
1714 * for operations such as listing all available fonts on the system,
1715 * and it is expected that most applications will need to use a more
1716 * comprehensive font handling and text layout library in addition to
1721 * a font family name, encoded in UTF-8
1723 * the slant for the font
1725 * the weight for the font
1727 public void selectFontFace(char[] family
, cairo_font_slant_t slant
, cairo_font_weight_t weight
)
1729 // void cairo_select_font_face (cairo_t *cr, const char *family, cairo_font_slant_t slant, cairo_font_weight_t weight);
1730 cairo_select_font_face(cairo
, Str
.toStringz(family
), slant
, weight
);
1734 * Sets the current font matrix to a scale by a factor of size, replacing
1735 * any font matrix previously set with cairo_set_font_size() or
1736 * cairo_set_font_matrix(). This results in a font size of size user space
1737 * units. (More precisely, this matrix will result in the font's
1738 * em-square being a size by size square in user space.)
1742 * the new font size, in user space units
1744 public void setFontSize(double size
)
1746 // void cairo_set_font_size (cairo_t *cr, double size);
1747 cairo_set_font_size(cairo
, size
);
1751 * Sets the current font matrix to matrix. The font matrix gives a
1752 * transformation from the design space of the font (in this space,
1753 * the em-square is 1 unit by 1 unit) to user space. Normally, a
1754 * simple scale is used (see cairo_set_font_size()), but a more
1755 * complex font matrix can be used to shear the font
1756 * or stretch it unequally along the two axes
1760 * a cairo_matrix_t describing a transform to be applied to
1763 public void setFontMatrix(cairo_matrix_t
* matrix
)
1765 // void cairo_set_font_matrix (cairo_t *cr, const cairo_matrix_t *matrix);
1766 cairo_set_font_matrix(cairo
, matrix
);
1770 * Stores the current font matrix into matrix. See
1771 * cairo_set_font_matrix().
1775 * return value for the matrix
1777 public void getFontMatrix(cairo_matrix_t
* matrix
)
1779 // void cairo_get_font_matrix (cairo_t *cr, cairo_matrix_t *matrix);
1780 cairo_get_font_matrix(cairo
, matrix
);
1784 * Sets a set of custom font rendering options for the cairo_t.
1785 * Rendering options are derived by merging these options with the
1786 * options derived from underlying surface; if the value in options
1787 * has a default value (like CAIRO_ANTIALIAS_DEFAULT), then the value
1788 * from the surface is used.
1792 * font options to use
1794 public void setFontOptions(cairo_font_options_t
* options
)
1796 // void cairo_set_font_options (cairo_t *cr, const cairo_font_options_t *options);
1797 cairo_set_font_options(cairo
, options
);
1801 * Retrieves font rendering options set via cairo_set_font_options.
1802 * Note that the returned options do not include any options derived
1803 * from the underlying surface; they are literally the options
1804 * passed to cairo_set_font_options().
1808 * a cairo_font_options_t object into which to store
1809 * the retrieved options. All existing values are overwritten
1811 public void getFontOptions(cairo_font_options_t
* options
)
1813 // void cairo_get_font_options (cairo_t *cr, cairo_font_options_t *options);
1814 cairo_get_font_options(cairo
, options
);
1818 * A drawing operator that generates the shape from a string of UTF-8
1819 * characters, rendered according to the current font_face, font_size
1820 * (font_matrix), and font_options.
1821 * This function first computes a set of glyphs for the string of
1822 * text. The first glyph is placed so that its origin is at the
1823 * current point. The origin of each subsequent glyph is offset from
1824 * that of the previous glyph by the advance values of the previous
1826 * After this call the current point is moved to the origin of where
1827 * the next glyph would be placed in this same progression. That is,
1828 * the current point will be at the origin of the final glyph offset
1829 * by its advance values. This allows for easy display of a single
1830 * logical string with multiple calls to cairo_show_text().
1831 * NOTE: The cairo_show_text() function call is part of what the cairo
1832 * designers call the "toy" text API. It is convenient for short demos
1833 * and simple programs, but it is not expected to be adequate for the
1834 * most serious of text-using applications. See cairo_show_glyphs()
1835 * for the "real" text display API in cairo.
1839 * a string of text encoded in UTF-8
1841 public void showText(char[] utf8
)
1843 // void cairo_show_text (cairo_t *cr, const char *utf8);
1844 cairo_show_text(cairo
, Str
.toStringz(utf8
));
1852 public void showGlyphs(cairo_glyph_t
* glyphs
, int numGlyphs
)
1854 // void cairo_show_glyphs (cairo_t *cr, cairo_glyph_t *glyphs, int num_glyphs);
1855 cairo_show_glyphs(cairo
, glyphs
, numGlyphs
);
1859 * Gets the current font face for a cairo_t.
1863 * the current font object. Can return NULL
1864 * on out-of-memory or if the context is already in
1865 * an error state. This object is owned by cairo. To keep
1866 * a reference to it, you must call cairo_font_face_reference().
1868 public cairo_font_face_t
* getFontFace()
1870 // cairo_font_face_t* cairo_get_font_face (cairo_t *cr);
1871 return cairo_get_font_face(cairo
);
1875 * Gets the font extents for the currently selected font.
1879 * a cairo_font_extents_t object into which the results
1882 public void fontExtents(cairo_font_extents_t
* extents
)
1884 // void cairo_font_extents (cairo_t *cr, cairo_font_extents_t *extents);
1885 cairo_font_extents(cairo
, extents
);
1889 * Replaces the current cairo_font_face_t object in the cairo_t with
1890 * font_face. The replaced font face in the cairo_t will be
1891 * destroyed if there are no other references to it.
1895 * a cairo_font_face_t, or NULL to restore to the default font
1897 public void setFontFace(cairo_font_face_t
* fontFace
)
1899 // void cairo_set_font_face (cairo_t *cr, cairo_font_face_t *font_face);
1900 cairo_set_font_face(cairo
, fontFace
);
1904 * Replaces the current font face, font matrix, and font options in
1905 * the cairo_t with those of the cairo_scaled_font_t. Except for
1906 * some translation, the current CTM of the cairo_t should be the
1907 * same as that of the cairo_scaled_font_t, which can be accessed
1908 * using cairo_scaled_font_get_ctm().
1912 * a cairo_scaled_font_t
1915 public void setScaledFont(cairo_scaled_font_t
* scaledFont
)
1917 // void cairo_set_scaled_font (cairo_t *cr, const cairo_scaled_font_t *scaled_font);
1918 cairo_set_scaled_font(cairo
, scaledFont
);
1922 * Gets the extents for a string of text. The extents describe a
1923 * user-space rectangle that encloses the "inked" portion of the text,
1924 * (as it would be drawn by cairo_show_text()). Additionally, the
1925 * x_advance and y_advance values indicate the amount by which the
1926 * current point would be advanced by cairo_show_text().
1927 * Note that whitespace characters do not directly contribute to the
1928 * size of the rectangle (extents.width and extents.height). They do
1929 * contribute indirectly by changing the position of non-whitespace
1930 * characters. In particular, trailing whitespace characters are
1931 * likely to not affect the size of the rectangle, though they will
1932 * affect the x_advance and y_advance values.
1936 * a string of text, encoded in UTF-8
1938 * a cairo_text_extents_t object into which the results
1941 public void textExtents(char[] utf8
, cairo_text_extents_t
* extents
)
1943 // void cairo_text_extents (cairo_t *cr, const char *utf8, cairo_text_extents_t *extents);
1944 cairo_text_extents(cairo
, Str
.toStringz(utf8
), extents
);
1948 * Gets the extents for an array of glyphs. The extents describe a
1949 * user-space rectangle that encloses the "inked" portion of the
1950 * glyphs, (as they would be drawn by cairo_show_glyphs()).
1951 * Additionally, the x_advance and y_advance values indicate the
1952 * amount by which the current point would be advanced by
1953 * cairo_show_glyphs.
1954 * Note that whitespace glyphs do not contribute to the size of the
1955 * rectangle (extents.width and extents.height).
1959 * an array of cairo_glyph_t objects
1961 * the number of elements in glyphs
1963 * a cairo_text_extents_t object into which the results
1966 public void glyphExtents(cairo_glyph_t
* glyphs
, int numGlyphs
, cairo_text_extents_t
* extents
)
1968 // void cairo_glyph_extents (cairo_t *cr, cairo_glyph_t *glyphs, int num_glyphs, cairo_text_extents_t *extents);
1969 cairo_glyph_extents(cairo
, glyphs
, numGlyphs
, extents
);