gfngfn / SATySFi

A statically-typed, functional typesetting system
GNU Lesser General Public License v3.0
1.16k stars 82 forks source link

Allow users to inspect/manipulate path data #217

Open yuhr opened 4 years ago

yuhr commented 4 years ago

Hello, I'm going to make a library which improves experience of SATySFi's graphics functionality, especially flexibility to draw complex diagrams.

The concern is, if we want to do some complex manipulation on paths, it instantly becomes required to access internal representations of paths. How do you think about exposing these repres as some primitive? (Somehow, for example, converting path and pre-path to something like path-element list and back?)

On my local proof-of-concept work, some interesting functions achieved using existing current_point and implementing (on OCaml's side) current_tangent which returns current tangent of a prepath. See below:

Screenshot 2020-02-16 at 23 37 30

(These functions are implemented as SATySFi code, with the exception of current-point and current-tangent)

But I believe it is super exciting if entire path data become available to users so that we can write useful functions on user's side. I'll not be thrilled to touch SATySFi's OCaml implementation (that is, maybe, having breaking changes and/or bloating standard APIs) in order to implement complex functions, such as boolean operations, cutting and joining of paths.

Anotherly if such operations are to be implemented as standard APIs, there'd be nothing to stop me sending PRs about this constantly to SATySFi though... but even so, I think there should be some ways to access raw path data as a kind of last resort for diagram-oriented users 👻

yuhr commented 4 years ago

After some inspect I've noticed that SATySFi's path implementation is sufficient and almost straitforward to the path construction operators that PDF supports, and all I need to do is just "map" exactly the same structure of path repres in OCaml into SATySFi code. Seems I need more inspect on PDF spec.