[cairo] Path_extents after coordinate system is rotated.

Lawrence D'Oliveiro ldo at geek-central.gen.nz
Fri Apr 10 19:43:18 PDT 2015


On Wed, 08 Apr 2015 15:05:31 +0200, Stefan Salewski wrote:

> Seems that new path_extents() after rotation is not
> calculated from path itself, but from initial path_extents().

Ah, but what happens if you, say, rotate the coordinate system before
constructing the path, and leave it rotated while asking for the
path_extents?

Given

    import qahirah

    ctx = qahirah.Context.create_for_dummy()
    path_rect = qahirah.Rect(-0.5, -0.5, 1, 1)

then

    print \
      (
        ctx
            .identity_matrix()
            .new_path()
            .rectangle(path_rect)
            .path_extents
      )

prints

    Rect(-0.5, -0.5, 1, 1)

which makes perfect sense.

    print \
      (
        ctx
            .identity_matrix()
            .new_path()
            .rotate(45 * qahirah.deg)
            .rectangle(path_rect)
            .rotate(-45 * qahirah.deg)
            .path_extents
      )

prints

    Rect(-0.707031, -0.707031, 1.41406, 1.41406)

which also makes sense, as does

    print \
      (
        ctx
            .identity_matrix()
            .new_path()
            .rectangle(path_rect)
            .rotate(-45 * qahirah.deg)
            .path_extents
      )

giving

    Rect(-0.707107, -0.707107, 1.41421, 1.41421)

since cairo_rectangle_t has to be axis-aligned.

However,

    print \
      (
        ctx
            .identity_matrix()
            .new_path()
            .rotate(45 * qahirah.deg)
            .rectangle(path_rect)
            .path_extents
      )

prints

    Rect(-0.999893, -0.999893, 1.99979, 1.99979)

which I find quite surprising.


More information about the cairo mailing list