Package: cairo

Function cairo:surface-device-scale

Lambda List

cairo:surface-device-scale (surface)

Syntax

(cairo:surface-device-scale surface) => xscale, yscale
(setf (cairo:surface-device-scale surface) (list xscale yscale))

Arguments

surface -- a cairo:surface-t instance
xscale -- a number coerced to a double float for the scale in the x direction, in device units
yscale -- a number coerced to a double float for the scale in the y direction, in device units

Details

The cairo:surface-device-scale function returns the device scale. The (setf cairo:surface-device-scale) function sets a scale that is multiplied to the device coordinates determined by the current transformation matrix CTM when drawing to surface.

One common use for this is to render to very high resolution display devices at a scale factor, so that code that assumes 1 pixel will be a certain size will still work. Setting a transformation via the cairo:scale function is not sufficient to do this, since functions like the cairo:device-to-user function will expose the hidden scale.

Note that the scale affects drawing to the surface as well as using the surface in a source pattern.
 

See also

2025-1-18