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

Lawrence D'Oliveiro ldo at geek-central.gen.nz
Thu Mar 12 00:05:16 PDT 2015

```On Thu, 12 Mar 2015 07:37:50 +0100, Olaf Schmidt wrote:

> Am 12.03.2015 um 00:09 schrieb Lawrence D'Oliveiro:
>
>> So your version ends up full of hard-coded numbers.
>> Which you had to get from the formulas in my version!
>
> Now, now - you don't really want to sell me, that the
> simplest trigon. math functions were your own invention,
> will you?

Just compare your version, hard coded to 4 patterns across:

CC.Rectangle (i Mod 4 + 1) * TOf + (i Mod 4) * TS, IIf(i < 4, TOf, 2 * TOf + TS), TS, TS

with my version:

ctx.rectangle(Rect.from_dimensions(figure_bounds) + Vector(i, 0) * (figure_bounds + margins) + margins)

which can do any number.

> An equilateral triangle which stands on one side, will
> have a certain aspect-ratio to its bounding rectangle.
>
> E.g.:
> sin(120 * PI / 360) = 0.866025403784439
> or
> sqrt(3) / 2 = 0.866025403784439
>
> Ergo, I've choosen my pattern-size appropriately:
> 26 / 30 = 0,866666666666667
> (since meeting certain Pixel-Boundaries is important for patterns,
> which are placed with "Extend-Repeat" on image-surfaces)

Forgetting that Cairo does fractional coordinates and anti-aliasing.

> First, let's introduce the proper even-odd fill-rule for this

Even-odd fill rule is wrong for this example. I wondered why you did
that: so it was to cover up your misunderstanding of the maths.

> I guess you're operating under the prejudice, that *any* VB-Developer
> has to be some kind of idiot ...

You said it, I didnâ€™t.
```