Creates a new Context with all graphics state parameters set to default values and with target as a target surface. The target surface should be constructed with a backend-specific function such as new ImageSurface().
Create a Context from a existing cairo_t*. Context is a garbage collected class. It will call cairo_destroy when it gets collected by the GC or when dispose() is called.
A destructor is present on this object, but not explicitly documented in the source.
Constructor that tracks the reference count appropriately. If !refCountedIsInitialized, does nothing.
convenience alias
convenience alias
convenience alias
convenience alias
Append the path onto the current path. The path may be the return value from one of copyPath() or copyPathFlat().
appendPath for user created paths. There is no high level API for user defined paths. Use appendPath(Path p) for paths which were obtained from cairo.
Adds a circular arc of the given radius to the current path. The arc is centered at center, begins at angle1 and proceeds in the direction of increasing angles to end at angle2. If angle2 is less than angle1 it will be progressively increased by 2*PI until it is greater than angle1.
Adds a circular arc of the given radius to the current path. The arc is centered at center, begins at angle1 and proceeds in the direction of decreasing angles to end at angle2. If angle2 is greater than angle1 it will be progressively decreased by 2*PI until it is less than angle1.
Establishes a new clip region by intersecting the current clip region with the current path as it would be filled by fill() and according to the current fill rule (see setFillRule()).
Computes a bounding box in user coordinates covering the area inside the current clip.
Establishes a new clip region by intersecting the current clip region with the current path as it would be filled by fill() and according to the current fill rule (see setFillRule()).
Adds a line segment to the path from the current point to the beginning of the current sub-path, (the most recent point passed to moveTo()), and closes this sub-path. After this call the current point will be at the joined endpoint of the sub-path.
Gets the current clip region as a list of rectangles in user coordinates.
Emits the current page for backends that support multiple pages, but doesn't clear it, so, the contents of the current page will be retained for the next page too. Use showPage() if you want to get an empty page after the emission.
Adds a cubic Bézier spline to the path from the current point to position p3 in user-space coordinates, using p1 and p2 as the control points. After this call the current point will be p3.
Transform a coordinate from device space to user space by multiplying the given point by the inverse of the current transformation matrix (CTM).
Transform a distance vector from device space to user space. This function is similar to deviceToUser() except that the translation components of the inverse CTM will be ignored when transforming inp.
Explicitly drecrease the reference count.
A drawing operator that fills the current path according to the current fill rule, (each sub-path is implicitly closed before being filled). After cfill(), the current path will be cleared from the cairo context. See setFillRule() and fillPreserve().
Computes a bounding box in user coordinates covering the area that would be affected, (the "inked" area), by a fill() operation given the current path and fill parameters. If the current path is empty, returns an empty rectangle ((0,0), (0,0)). Surface dimensions and clipping are not taken into account.
A drawing operator that fills the current path according to the current fill rule, (each sub-path is implicitly closed before being filled). Unlike fill(), fillPreserve() preserves the path within the cairo context.
Gets the font extents for the currently selected font.
Gets the current shape antialiasing mode, as set by setAntiAlias.
Gets the current point of the current path, which is conceptually the final point reached by the path so far.
Gets the current dash array.
This function returns the length of the dash array in cr (0 if dashing is not currently in effect).
Gets the current fill rule, as set by setFillRule.
Gets the current font face for a Context.
Returns the current font matrix. See setFontMatrix.
Retrieves font rendering options set via setFontOptions(). Note that the returned options do not include any options derived from the underlying surface; they are literally the options passed to setFontOptions().
Gets the current destination surface for the context. This is either the original target surface as passed to the Context constructor or the target surface for the current group as started by the most recent call to Context.pushGroup() or Context.pushGroup(Content).
Gets the current line cap style, as set by setLineCap().
Gets the current line join style, as set by setLineJoin
This function returns the current line width value exactly as set by cairo_set_line_width(). Note that the value is unchanged even if the CTM has changed between the calls to setLineWidth() and getLineWidth().
Returns the current transformation matrix (CTM)
Gets the current miter limit, as set by setMiterLimit
Gets the current compositing operator for a cairo context.
Gets the current scaled font for a Context.
Gets the current source pattern for cr.
Gets the target surface for the cairo context as passed to the constructor.
Gets the current tolerance value, as set by setTolerance
Gets the extents for an array of glyphs. The extents describe a user-space rectangle that encloses the "inked" portion of the glyphs, (as they would be drawn by showGlyphs()). Additionally, the x_advance and y_advance values indicate the amount by which the current point would be advanced by showGlyphs().
Adds closed paths for the glyphs to the current path. The generated path if filled, achieves an effect similar to that of showGlyphs().
Returns whether a current point is defined on the current path. See getCurrentPoint() for details on the current point.
Resets the current transformation matrix (CTM) by setting it equal to the identity matrix. That is, the user-space and device-space axes will be aligned and one user-space unit will transform to one device-space unit.
Tests whether the given point is inside the area that would be visible through the current clip, i.e. the area that would be filled by a cairo_paint() operation.
Tests whether the given point is inside the area that would be affected by a cairo_fill() operation given the current path and filling parameters. Surface dimensions and clipping are not taken into account.
Tests whether the given point is inside the area that would be affected by a cairo_stroke() operation given the current path and stroking parameters. Surface dimensions and clipping are not taken into account.
Adds a line to the path from the current point to position p1 in user-space coordinates. After this call the current point will be p1.
A drawing operator that paints the current source using the alpha channel of pattern as a mask. (Opaque areas of pattern are painted with the source, transparent areas are not painted.)
A drawing operator that paints the current source using the alpha channel of surface as a mask. (Opaque areas of surface are painted with the source, transparent areas are not painted.)
Begin a new sub-path. After this call the current point will be p1.
Clears the current path. After this call there will be no path and no current point.
Begin a new sub-path. Note that the existing path is not affected. After this call there will be no current point.
Assignment operator
A drawing operator that paints the current source everywhere within the current clip region.
A drawing operator that paints the current source everywhere within the current clip region using a mask of constant alpha value alpha. The effect is similar to paint(), but the drawing is faded out using the alpha value.
Computes a bounding box in user-space coordinates covering the points on the current path. If the current path is empty, returns an empty Box ((0,0), (0,0)). Stroke parameters, fill rule, surface dimensions and clipping are not taken into account.
Terminates the redirection begun by a call to Context.pushGroup() or Context.pushGroup(Content) and returns a new pattern containing the results of all drawing operations performed to the group.
Terminates the redirection begun by a call to Context.pushGroup() or Context.pushGroup(Content) and installs the resulting pattern as the source pattern in the given cairo context.
Temporarily redirects drawing to an intermediate surface known as a group. The redirection lasts until the group is completed by a call to Context.popGroup() or Context.popGroupToSource(). These calls provide the result of any drawing to the group as a pattern, (either as an explicit object, or set as the source pattern).
Temporarily redirects drawing to an intermediate surface known as a group. The redirection lasts until the group is completed by a call to Context.popGroup() or Context.popGroupToSource(). These calls provide the result of any drawing to the group as a pattern, (either as an explicit object, or set as the source pattern).
Adds a closed sub-path rectangle of the given size to the current path at position r.point in user-space coordinates. This function is logically equivalent to:
Relative-coordinate version of curveTo(). All offsets are relative to the current point. Adds a cubic Bézier spline to the path from the current point to a point offset from the current point by rp3, using points offset by rp1 and rp2 as the control points. After this call the current point will be offset by rp3.
Relative-coordinate version of lineTo(). Adds a line to the path from the current point to a point that is offset from the current point by rp1 in user space. After this call the current point will be offset by rp1.
Begin a new sub-path. After this call the current point will offset by rp1.
Reset the current clip region to its original, unrestricted state. That is, set the clip region to an infinitely large shape containing the target surface. Equivalently, if infinity is too hard to grasp, one can imagine the clip region being reset to the exact bounds of the target surface.
Restores cr to the state saved by a preceding call to Context.save() and removes that state from the stack of saved states.
Modifies the current transformation matrix (CTM) by rotating the user-space axes by angle radians. The rotation of the axes takes places after any existing transformation of user space. The rotation direction for positive angles is from the positive X axis toward the positive Y axis.
Makes a copy of the current state of cr and saves it on an internal stack of saved states for cr. When Context.restore() is called, cr will be restored to the saved state. Multiple calls to Context.save() and Context.restore() can be nested; each call to Context.restore() restores the state from the matching paired Context.save().
Modifies the current transformation matrix (CTM) by scaling the X and Y user-space axes by sx and sy respectively. The scaling of the axes takes place after any existing transformation of user space.
Modifies the current transformation matrix (CTM) by scaling the X and Y user-space axes by sx and sy respectively. The scaling of the axes takes place after any existing transformation of user space.
Note: The selectFontFace() function call is part of what the cairo designers call the "toy" text API. It is convenient for short demos and simple programs, but it is not expected to be adequate for serious text-using applications.
Set the antialiasing mode of the rasterizer used for drawing shapes. This value is a hint, and a particular backend may or may not support a particular value. At the current time, no backend supports CAIRO_ANTIALIAS_SUBPIXEL when drawing shapes.
Sets the dash pattern to be used by stroke(). A dash pattern is specified by dashes, an array of positive values. Each value provides the length of alternate "on" and "off" portions of the stroke. The offset specifies an offset into the pattern at which the stroke begins.
Sets the current font matrix to matrix. The font matrix gives a transformation from the design space of the font (in this space, the em-square is 1 unit by 1 unit) to user space. Normally, a simple scale is used (see setFontSize()), but a more complex font matrix can be used to shear the font or stretch it unequally along the two axes
Sets a set of custom font rendering options for the Context. Rendering options are derived by merging these options with the options derived from underlying surface; if the value in options has a default value (like CAIRO_ANTIALIAS_DEFAULT), then the value from the surface is used.
Sets the current font matrix to a scale by a factor of size, replacing any font matrix previously set with setFontSize() or setFontMatrix(). This results in a font size of size user space units. (More precisely, this matrix will result in the font's em-square being a size by size square in user space.)
Sets the current line cap style within the cairo context. See LineCap for details about how the available line cap styles are drawn.
Sets the current line join style within the cairo context. See LineJoin for details about how the available line join styles are drawn.
Sets the current line width within the cairo context. The line width value specifies the diameter of a pen that is circular in user space, (though device-space pen may be an ellipse in general due to scaling/shear/rotation of the CTM).
Modifies the current transformation matrix (CTM) by setting it equal to matrix.
Sets the current miter limit within the cairo context.
Sets the compositing operator to be used for all drawing operations. See Operator for details on the semantics of each available compositing operator.
Replaces the current font face, font matrix, and font options in the Context with those of the ScaledFont. Except for some translation, the current CTM of the cairo_t should be the same as that of the ScaledFont, which can be accessed using ScaledFont.getCTM().
Sets the source pattern within cr to source. This pattern will then be used for any subsequent drawing operation until a new source pattern is set.
Sets the source pattern within cr to an opaque color. This opaque color will then be used for any subsequent drawing operation until a new source pattern is set.
Sets the source pattern within cr to a translucent color. This color will then be used for any subsequent drawing operation until a new source pattern is set.
This is a convenience function for creating a pattern from surface and setting it as the source in cr with Context.setSource().
Sets the tolerance used when converting paths into trapezoids. Curved segments of the path will be subdivided until the maximum deviation between the original path and the polygonal approximation is less than tolerance. The default value is 0.1. A larger value will give better performance, a smaller value, better appearance. (Reducing the value from the default value of 0.1 is unlikely to improve appearance significantly.) The accuracy of paths within Cairo is limited by the precision of its internal arithmetic, and the prescribed tolerance is restricted to the smallest representable internal value.
A drawing operator that generates the shape from an array of glyphs, rendered according to the current fontFace, fontSize (fontMatrix), and font options.
Emits and clears the current page for backends that support multiple pages. Use copyPage() if you don't want to clear the page.
A drawing operator that generates the shape from a string of UTF-8 characters, rendered according to the current fontFace, fontSize (fontMatrix), and fontOptions.
This operation has rendering effects similar to showGlyphs() but, if the target surface supports it, uses the provided text and cluster mapping to embed the text for the glyphs shown in the output. If the target does not support the extended attributes, this function acts like the basic showGlyphs().
A drawing operator that strokes the current path according to the current line width, line join, line cap, and dash settings. After stroke(), the current path will be cleared from the cairo context. See setLineWidth(), setLineJoin(), setLineCap(), setDash(), and strokePreserve().
Computes a bounding box in user coordinates covering the area that would be affected, (the "inked" area), by a stroke() operation given the current path and stroke parameters. If the current path is empty, returns an empty rectangle ((0,0), (0,0)). Surface dimensions and clipping are not taken into account.
A drawing operator that strokes the current path according to the current line width, line join, line cap, and dash settings. Unlike stroke(), strokePreserve() preserves the path within the cairo context.
Adds closed paths for text to the current path. The generated path if filled, achieves an effect similar to that of showText().
Modifies the current transformation matrix (CTM) by applying matrix as an additional transformation. The new transformation of user space takes place after any existing transformation.
Modifies the current transformation matrix (CTM) by translating the user-space origin by (tx, ty). This offset is interpreted as a user-space coordinate according to the CTM in place before the new call to translate(). In other words, the translation of the user-space origin takes place after any existing transformation.
Transform a coordinate from user space to device space by multiplying the given point by the current transformation matrix (CTM).
Transform a distance vector from user space to device space. This function is similar to userToDevice() except that the translation components of the CTM will be ignored when transforming inp.
Convenience property
Convenience property
Convenience property
Convenience property
Convenience property
Convenience property
Convenience property
Convenience property
Convenience property
Convenience property
Convenience property
Convenience property
Convenience property
Convenience property
Convenience property
Enable / disable memory management debugging for this Context instance. Only available if both cairoD and the cairoD user code were compiled with "debug=RefCounted"
The underlying cairo_t* handle
The cairo drawing context
Context is the main object used when drawing with cairo. To draw with cairo, you create a Context, set the target surface, and drawing options for the Context, create shapes with functions like Context.moveTo() and Context.lineTo(), and then draw shapes with Context.stroke() or Context.fill().
Context's can be pushed to a stack via Context.save(). They may then safely be changed, without loosing the current state. Use Context.restore() to restore to the saved state.