Name
csurface:CreateSimilar -- create similar surface
Synopsis
handle = csurface:CreateSimilar(content, width, height)
Function
Create a new surface that is as compatible as possible with an existing surface. For example the new surface will have the same device scale, fallback resolution and font options as the source surface. Generally, the new surface will also use the same backend as the source surface, unless that is not possible for some reason. The type of the returned surface may be examined with csurface:GetType().

The content parameter can be set to one of the following constants:

#CAIRO_CONTENT_COLOR
The surface will hold color content only.
#CAIRO_CONTENT_ALPHA
The surface will hold alpha content only.
#CAIRO_CONTENT_COLOR_ALPHA
The surface will hold color and alpha content.

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

Use csurface:CreateSimilarImage() if you need an image surface which can be painted quickly to the target surface.

This function returns a handle to the newly allocated surface. The caller owns the surface and should call csurface:Free() when done with it.

This function always returns a valid handle, but it will return a handle to a "nil" surface if the source surface is already in an error state or any other error occurs.

Inputs
content
the content for the new surface (see above)
width
width of the new surface, (in device-space units)
height
height of the new surface (in device-space units)
Results
handle
handle to a new surface

Show TOC