[cairo] Pattern-Context Matrix

Lawrence D'Oliveiro ldo at geek-central.gen.nz
Sun Mar 29 14:17:28 PDT 2015


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>.


More information about the cairo mailing list