To do some drawing in PyCairo, we must first create a `Drawing Context`.
The drawing context holds all of the graphics state parameters that describe how drawing is to be done.
This includes information such as line width, color, the surface to draw to, and many other things.
It allows the actual drawing functions to take fewer arguments to simplify the interface.
A `Path` is a collection of points used to create primitive shapes such as lines, arcs, and curves. There are two kinds of paths: open and closed paths.
In a closed path, starting and ending points meet. In an open path, starting and ending point do not meet. In PyCairo, we start with an empty path.
First, we define a path and then we make them visible by stroking and/or filling them. After each `stroke()` or `fill()` method call, the path is emptied.
We have to define a new path. If we want to keep the existing path for later drawing, we can use the `stroke_preserve()` and `fill_preserve()` methods.
A `Source` is the paint we use in drawing. We can compare the source to a pen or ink that we use to draw the outlines and fill the shapes.
There are four kinds of basic sources: colors, gradients, patterns, and images.
A `Surface` is a destination that we are drawing to. We can render documents using the PDF or PostScript surfaces, directly draw to a platform via the Xlib and Win32 surfaces.
Before the source is applied to the surface, it is filtered first. The `Mask` is used as a filter.
It determines where the source is applied and where not. Opaque parts of the mask allow to copy the source.
Transparent parts do not let to copy the source to the surface.
A `Pattern` represents a source when drawing onto a surface.
In PyCairo, a pattern is something that you can read from and that is used as the source or mask of a drawing operation.
Patterns can be solid, surface-based, or gradients.
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.
### Fill
A drawing operator that fills the current path according to the current *fill rule*.
(each sub-path is implicitly closed before being filled).
After `fill()`, the current path will be cleared from the Context.
`context.set_fill_rule(fill_rule)` set a FILL RULE to the cairo context.
For both fill rules, whether or not a point is included in the fill is determined by taking a ray from that point to infinity and looking at intersections with the path.
The ray can be in any direction, as long as it doesn't pass through the end point of a segment or have a tricky intersection such as intersecting tangent to the path.
surface.copy_page() # Emits the current page for backends that support multiple pages, but doesn't clear it, so that the contents of the current page will be retained for the next page. Use show_page() if you want to get an empty page after the emission.