This is roughly a copy of the sample code listed at cairographics.org/samples. These examples are C code and assume that you've already set up a Cairo surface and Cairo Context.
This (samples) directory contains ports of these examples to julia, additionally creating the Surface and Context, adding a time-stamp to the image, and saving the result to a .png file.
Example of using the arc path operator sample_arc.jl. Note: The path creation starts without current point, otherwise there would be a linesegment first, before starting of the arc.
Example of using the arc_negative path operator sample_arc_negative.jl.
A clip path, a circle is defined, then the drawing is done sample_clip.jl.
Like the previous, but now inserting a picture by reading a .png to an Image Surface. Note: the function is called read_from_png and creates an Image Surface; while in pure C cairo this would be a call of cairo_image_surface_create_from_png sample_clip_image.jl.
Example of more complex path construction, here a rectangle constructed be four bezier segments. Note: Different as in the original example, this here now puts the path construction and stroke and fill operations into a function with coordinates and corner radius as arguments sample_curve_rectangle.jl.
Example of using the curve to path operator, which adds a cubic Bézier spline to the current path sample_curve_to.jl.
Example of using a dash line pattern for stroking a path. Note: the julia set_dash uses the length of the dash array to set the ndash internally sample_dash.jl.
Example of creating a path of non connected areas and fill - while preserving the path - and stroke sample_fill_and_stroke2.jl.
Exmaple of using the different fill rules. The same path is filled and stroked sample_fill_style.jl. Note: the julia function is called set_fill_type while the pure C cairo is called with set_fill_rule.
Example of gradients - both linear and radiant - as definition and used for filling sample_gradient.jl.
Example of painting with a Image Surface as source sample_image.jl.
Example of painting with a Image Surface as pattern [sample_imagepattern.jl] (sample_imagepattern.jl).
Example of stroking a path with non connected segments sample_multi_segment_caps.jl.
Example of more path operators, custom shape could be wrapped in a function sample_rounded_rectangle.jl.
Examples of the line cap settings sample_set_line_cap.jl.
Examples of the line join settings sample_set_line_join.jl.
Example of setting text, one with text_show, second with text_path extending the current path and fill and stroke the outline sample_text.jl.
Example of getting the text extents, then centering the text around 128.0,128.0 sample_text_align_center.jl.
Example of getting the text extents, plotting the dimension sample_text_extents.jl.
Example of getting the path to a single character via text_path, copy_path and convert to an Array of CairoPathEntry sample_copy_path.jl.