Re: Path_extents after coordinate system is rotated.

Lawrence D'Oliveiro <[email protected]>
Newsgroups gmane.comp.lib.cairo
Organization Geek Central
Message-ID <[email protected]>
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.
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.