[cairo] Pattern-Context Matrix

Bill Spitzak spitzak at gmail.com
Mon Mar 30 10:47:20 PDT 2015

On 03/29/2015 02:17 PM, Lawrence D'Oliveiro wrote:
> When a pattern is set as the source on a context, a separate copy is
> made of the context matrix for mapping the pattern to user space. This
> copy remains unchanged on subsequent calls that affect the context
> matrix (set_matrix, transform etc), so the pattern doesn’t move as you
> move youe shapes around. This separate matrix doesn’t seem to have a
> name, so I call it the “pattern-context matrix” (as distinct from the
> “pattern matrix” and the “context matrix”).
> Even though this is part of the caller-visible state of a context,
> there is no direct API for changing it, other than by setting the
> source again. Even setting it to the same source as before does the
> trick, viz the following Qahirah one-liner:
>      ctx.source = ctx.source
> I added a script
> <https://github.com/ldo/qahirah_examples/blob/master/pattern_context_matrix>
> to my qahirah_examples collection demonstrating the behaviour of this
> matrix. Output is here
> <http://default-cube.deviantart.com/art/Pattern-Context-Matrix-523017448>.

I think this is the correct behavior and should be preserved.

In fact there is a long-outstanding ER to do "line width locking" which 
is to reproduce this behavior for line settings. There are also similar 
problems with the current font, where some apis act this way and others 
recompute when the ctm changes.

More information about the cairo mailing list