[cairo] clipmask of multiple rects in different angles

Lawrence D'Oliveiro ldo at geek-central.gen.nz
Wed Jul 20 20:55:10 UTC 2016


On Wed, 20 Jul 2016 13:44:49 +0200, Enrico Weigelt, metux IT consult
wrote:

> But what about transformation matrices ? When are they applied ?
> For each draw new path element (cairo_rectangle, etc) or only on the
> final path ?

    import sys
    import qahirah as qah

    in_path = qah.Rect(-100, -100, 200, 200).to_path()

    ctx = qah.Context.create_for_dummy()
    out_path = \
        (ctx.new_path()
            .set_matrix(qah.Matrix.rotate(45 * qah.deg))
            .append_path(in_path)
            .set_matrix(qah.Matrix.identity)
            .copy_path()
        )

    sys.stdout.write("in_path = {}\n".format(in_path))
    sys.stdout.write("out_path = {}\n".format(out_path))

produces output

    in_path = Path((Path.Segment([Path.Point(Vector(-100, -100), False), Path.Point(Vector(100, -100), False), Path.Point(Vector(100, 100), False), Path.Point(Vector(-100, 100), False)], True),))
    out_path = Path((Path.Segment([Path.Point(Vector(0, -141.422), False), Path.Point(Vector(141.422, 0), False), Path.Point(Vector(0, 141.422), False), Path.Point(Vector(-141.422, 0), False), Path.Point(Vector(0, -141.422), False)], True),))


More information about the cairo mailing list