[cairo] [patch] enable projective transformations

Arjen Nienhuis a.g.nienhuis at gmail.com
Tue Aug 17 03:52:54 PDT 2010


> To use it for 3D transformations you would need 4x3 (and 4x4 if you
> want projections, too).
> The question was: what would 3D transformations be used for?
> (Remember: cairo uses 2D surfaces, thus the third dimension input
> would be constant and its output would get discarded "soon")
>

Use case: 2 windows with buttons that 'stick out'.

def draw_window(ctx, w):
  draw_background(ctx, w.background)
  ctx.save()
  ctx.translate_z(-10)
  draw_buttons(ctx, w.buttons)
  ctx.restore()

def main():
  draw_window(ctx, w1)
  ctx.rotate_y(0.5)
  ctx.translate(300, 0)
  draw_window(ctx, w2)

I think this needs a 4x3 matrix. You need the value of the rotation
around the y axis to make translate_z have the right effect.

The advantage of this model is that draw_background() and
draw_buttons() can use plain old 2d cairo code and still get the 3d
look.


More information about the cairo mailing list