[cairo] Qahirah: A High-Level Cairo API Binding For Python 3

Lawrence D'Oliveiro ldo at geek-central.gen.nz
Fri Mar 6 17:53:18 PST 2015


On Fri, 06 Mar 2015 18:34:51 -0700, Dan Raymond wrote:

>> Being done in Python, I can go beyond the language limitations of C,
>> which constrain Cairo itself.
> 
> Huh?  Higher level languages like Python are always more limiting
> than C.

From
<https://github.com/ldo/qahirah_examples/blob/master/alhambra_tiles>:

    # construct triwing pattern
    curve_factor = .7
    tilt = 30 / deg
    c0 = Matrix.rotate(30 / deg).map(Vector(1, 0))
    c3 = Matrix.rotate(- 120 / deg).map(c0)
    c1 = c0 + (c3 - c0).rotate(tilt) * curve_factor
    c2 = c3 + (c0 - c3).rotate(tilt) * curve_factor
    # actually centre part should be thinner, but that would require another curve segment

    elts = [Path.MoveTo(c0)]
    tips = []
    for i in range(3) :
        mat = Matrix.rotate(- i / 3 * 360 / deg)
        tips.append(mat.map(c0))
        elts.append(Path.CurveTo(c1, c2, c3).transform(mat))
    #end for
    elts.append(Path.Close())
    triwing = Path(elts)

How much C code would it take to do the same?


More information about the cairo mailing list