cairo-paths: Paths

Description Methods and Functions Detailed Description Structures Enums and Flags Author(s) References

Description

Creating paths and manipulating path data

Methods and Functions

cairoCopyPath(cr)
cairoCopyPathFlat(cr)
cairoAppendPath(cr, path)
cairoHasCurrentPoint(cr)
cairoGetCurrentPoint(cr, x, y)
cairoNewPath(cr)
cairoNewSubPath(cr)
cairoClosePath(cr)
cairoArc(cr, xc, yc, radius, angle1, angle2)
cairoArcNegative(cr, xc, yc, radius, angle1, angle2)
cairoCurveTo(cr, x1, y1, x2, y2, x3, y3)
cairoLineTo(cr, x, y)
cairoMoveTo(cr, x, y)
cairoRectangle(cr, x, y, width, height)
cairoGlyphPath(cr, glyphs)
cairoTextPath(cr, utf8)
cairoRelCurveTo(cr, dx1, dy1, dx2, dy2, dx3, dy3)
cairoRelLineTo(cr, dx, dy)
cairoRelMoveTo(cr, dx, dy)
cairoPathExtents(cr)

Detailed Description

Paths are the most basic drawing tools and are primarily used to implicitly generate simple masks.

Structures

CairoPath

A data structure for holding a path. This data structure serves as the return value for cairoCopyPath and cairoCopyPathFlat as well the input value for cairoAppendPath.

See CairoPathData for hints on how to iterate over the actual data within the path.

The num_data member gives the number of elements in the data array. This number is larger than the number of independent path portions (defined in CairoPathDataType), since the data includes both headers and coordinates for each portion. CairoPath is a transparent-type.

status

[CairoStatus] the current error status

data

[CairoPathData] the elements in the path

numData

[integer] the number of elements in the data list

CairoPathData

CairoPathData is used to represent the path data inside a CairoPath.

The data structure is designed to try to balance the demands of efficiency and ease-of-use. A path is represented as a list of CairoPathData, which is a union of headers and points.

Each portion of the path is represented by one or more elements in the list, (one header followed by 0 or more points). The length value of the header is the number of list elements for the current portion including the header, (ie. length == 1 + # of points), and where the number of points for each element type is as follows:

    %CAIRO_PATH_MOVE_TO:     1 point
    %CAIRO_PATH_LINE_TO:     1 point
    %CAIRO_PATH_CURVE_TO:    3 points
    %CAIRO_PATH_CLOSE_PATH:  0 points

The semantics and ordering of the coordinate values are consistent with cairoMoveTo, cairoLineTo, cairoCurveTo, and cairoClosePath.

Here is sample code for iterating through a ""

path <- cr$copyPath()$data

for (data in path) {
  switch(CairoPathDataType[attr(data, "type") + 1L],
         "move-to" = do_move_to_things(data[1], data[2]),
         "line-to" = do_line_to_things(data[1], data[2]),
         "curve-to" =  do_curve_to_things(data[1], data[2], data[3], data[4],
           data[5], data[6]),
         "close-path" = do_close_path_things())
}

As of cairo 1.4, cairo does not mind if there are more elements in a portion of the path than needed. Such elements can be used by users of the cairo API to hold extra values in the path data structure. For this reason, it is recommended that applications always use data->header.length to iterate over the path data, instead of hardcoding the number of elements for each element type. CairoPathData is a transparent-type.

Enums and Flags

CairoPathDataType

CairoPathData is used to describe the type of one portion of a path when represented as a CairoPath. See CairoPathData for details.

move-to

A move-to operation

line-to

A line-to operation

curve-to

A curve-to operation

close-path

A close-path operation

Author(s)

Derived by RGtkGen from GTK+ documentation

References

https://www.cairographics.org/manual/cairo-Paths.html


RGtk2 documentation built on Oct. 14, 2021, 5:08 p.m.

Related to cairo-paths in RGtk2...