Don't you just love writing this sort of thing :)
Lawrence D'Oliveiro
ldo at geek-central.gen.new_zealand
Sat Dec 6 02:32:13 EST 2008
In message
<c31acc05-4e91-4f65-a7c0-a11a140f57e2 at x14g2000yqk.googlegroups.com>, Istvan
Albert wrote:
> Originally, like many others here I said YIKES! but on a second read,
> it is not that bad. It actually grows on you.
>
> After looking at it one more time I found it neat, very concise
> without being unreadable.
The key thing is, it's functional, not procedural. Instead of a sequence of
statements performing actions, it uses expressions that compute values.
Here's another one (from <http://github.com/ldo/linear2d/tree>):
def MapRect(SrcRect, DstRect) :
"""returns a Matrix that does appropriate scaling and translation
to map the corners of SrcRect to DstRect."""
return \
(
Matrix.translation(- SrcRect.topleft())
*
Matrix.scaling(DstRect.dimensions() / SrcRect.dimensions())
*
Matrix.translation(DstRect.topleft())
)
#end MapRect
More information about the Python-list
mailing list