[cairo] Extracting The Scaling Component Of A Matrix
Lawrence D'Oliveiro
ldo at geek-central.gen.nz
Thu Dec 10 16:51:22 PST 2015
I just updated my “faux 3D ball” example
<https://github.com/ldo/python_pixman_examples/blob/master/faux_3d_ball>
to work with different resolutions just by changing a single parameter.
To do this, I had to properly size the convolution matrices in device
coordinates, when their sizes are given in user coordinates. Here’s how
I construct a matrix that implements just the scaling component of the
CTM in the Cairo context “ctx”:
scaling = Matrix.scale(ctx.user_to_device_distance(Vector(1, 1)))
This can be easily adapted to extracting the scaling component of a
given matrix “mat”:
scaling = Matrix.scale(mat.mapdelta(Vector(1, 1)))
Exercise: can you come up with a similarly simple expression for
extracting the angle of the rotation component of a matrix?
More information about the cairo
mailing list