Re: Qahirah: A High-Level Cairo API Binding For Python 3
Lawrence D'Oliveiro <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Organization | Geek Central |
| Message-ID | <[email protected]> |
On Wed, 11 Mar 2015 10:02:28 +0100, Olaf Schmidt wrote:
> Am 11.03.2015 um 08:33 schrieb Lawrence D'Oliveiro:
>
>> I see a number of limitations. You hard code the size of the
>> pattern, rather than deriving it from the size of the design
>> elements.
>
> As I see it, the temp-surfaces you create (to render your Wing-Shape-
> Patterns on) are roughly the same size finally (87x150).
So your version ends up full of hard-coded numbers. Which you had to
get from the formulas in my version!
Besides, I think my version has fewer statements than yours. Remember
that
(qah.Context(tile)
.set_matrix(Matrix.scale(pattern_res) * Matrix.translate(- path_bounds.topleft))
.set_source_colour(Colour.grey(1))
.set_operator(CAIRO.OPERATOR_SOURCE)
.paint()
.set_source_colour(Colour.grey(0))
.new_path()
.append_path(shape)
# need enough copies to cover neighbouring spots under all possible pattern parameters
.append_path(shape.transform(Matrix.translate(tips[2] - tips[1])))
.append_path(shape.transform(Matrix.translate(tips[0] - tips[1])))
.append_path(shape.transform(Matrix.translate((+ pattern_dimensions.x, 0))))
.append_path(shape.transform(Matrix.translate((- pattern_dimensions.x, 0))))
.append_path(shape.transform(Matrix.translate(tips[1] - tips[2])))
.append_path(shape.transform(Matrix.translate(tips[1] - tips[0])))
.fill()
)
is technically one Python statement.
>> Then I see things like
>>
>> For j = 0 To 3: For i = 0 To 3 + j
>>
>> So you have to make 22 separate copies of the pattern in order to
>> ensure there are no gaps. A bit excessive, don’t you think?
>
> I've just played it safe there...
In other words, you are taking a brute-force approach, rather than
trying to understand the maths to get it right.
>> My code is more general than yours.
>
> But feel free to come up with an example, where my implementation
> would choke (in your opinion).
Just adding more curve instances is easier in my code: you don’t have
to calculate the new layout, since the script will automatically
adjust to new row and column numbers.
>>> - is more near the cairo-base-API (and thus nearly 1:1 portable to
>>> C)
>>
>> Which is something I thought I made clear I was trying to get away
>> from.
>
> Not sure what you're trying to "get away from", when working near the
> cairo-API causes smaller, easier to understand code (for most of us).
If you don’t accept the goals of Qahirah, why are you bothering with it?
--
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo