Package: cairo

Function cairo:surface-create-similar

Lambda List

cairo:surface-create-similar (target content width height)

Arguments

target -- an existing cairo:surface-t instance used to select the backend of the new surface
content -- a cairo:content-t value for the content for the new surface
width -- an integer for the width of the new surface, in device-space units
height -- an integer for the height of the new surface, in device-space units

Return Value

The newly allocated cairo:surface-t instance. The caller owns the surface and should call the cairo:surface-destroy function when done with it. This function always returns a valid surface, but it will return a "nil" surface if target is already in an error state or any other error occurs.

Details

Create a new surface that is as compatible as possible with an existing surface. For example the new surface will have the same fallback resolution and font options as target. Generally, the new surface will also use the same backend as target, unless that is not possible for some reason. The type of the returned surface may be examined with the cairo:surface-type function.

Initially the surface contents are all 0 and transparent if contents have transparency, black otherwise.

Use the cairo:surface-create-similar-image function if you need an image surface which can be painted quickly to the target surface.
 

See also

2025-1-18