count of 1. The initial reference count should be released with [cairo.global.destroy] when you are done using the #cairo_t. This function never returns null. If memory cannot be allocated, a special #cairo_t object will be returned on which [cairo.context.Context.status] returns [cairo.types.Status.NoMemory]. If you attempt to target a surface which does not support writing (such as #cairo_mime_surface_t) then a [cairo.types.Status.WriteError] will be raised. You can use this object normally, but no drawing will be done.
create
fn
cairo.context.Context create(cairo.surface.Surface target)Creates a new #cairo_t 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 [cairo.global.imageSurfaceCreate] (or any other
<function>cairo_<emphasis>backend</emphasis>_surface_create(<!-- -->)</function>variant).
This function references target, so you can immediately call [cairo.surface.Surface.destroy] on it if you don't need to maintain a separate reference to it.
Parameters
target | target surface for the context |
Returns
a newly allocated #cairo_t with a reference