|
From: Michael S. <m-s...@us...> - 2011-07-04 10:35:58
|
Salut André and Jörg,
I added a module to imitate the path construction technique of
MetaPost. The original idea was to have a means to easily get
nice-looking smooth curves, for example to be used in simple cases of
function plotting. I was first considering to write a
graph.style.curve class, but did not know how to do this properly
without refined re-evaluation of points. Now, it would be rather a
deformer which takes the series of lines and turns it into curves. The
result is then at the responsability of the user (data representation
_is_ difficult).
In my first attempts, I tried to directly use the C code of MetaPost,
but there is so much initialisation going on, that I did not succeed.
So, I translated the C code, which is based on integer arithmetics
into double-based Python code. I left as much of the original
structure as I could (that's why there are so many functions _mp_*).
For the interface, I scratched my head for quite some time. The
essential task is to reasonably distribute the different properties of
the metapost knots (smooth tangents, curlyness, given direction,
endpoint, ... see mpman.pdf) to some classes. I now did it like this:
* For me, the tension is a property of the link, although what is
specified are the tensions at its end. This is why I have a
tensioncurve.
* If control points are specified manually, also the metapost language
only allows to specify both of them for one curve element. And I
think that is required also in the internals of the algorithm.
So, I kept that and made a controlcurve.
* The remaining three properties,
endpoint
curlyness
tangent direction
are kept as properties of the knots.
Please have a look at it to see whether the logics is consistent and
convenient in your minds as well. There are some examples in the
interface() routine of test/functional/test_mpost.py
Michael
|