abey79 / vsvg

Fast and portable tools for plotter users
http://whisk.rs
MIT License
106 stars 12 forks source link

Drawer API #5

Open abey79 opened 1 year ago

abey79 commented 1 year ago

Currently, vpype's offer in terms of drawing primitive is very weak: just a few functions to create corresponding np.array(dtype=complex): vpype.rect(), vpype.circle(), etc. To complement that, significant additional work is done by vsketch to implement its Processing-like API. Given the relative simplicity of the basic path type, this works relatively well.

The present work introduces a more complex path type that include cubic Bézier. Proper conversion from primitive (circle, arcs, elliptic arcs, rounded rects, etc.) has consequently become a bit more complex. To address that, I propose a plan to introduce a "Drawer API" to vpype-core with the following functionalities:

Advantages:

abey79 commented 1 year ago

As a first iteration, I'm splitting the drawer API in a separate, long-term DrawState structure (which contains the transform, color, etc.) and a short-term Draw structure, which is linked to a target layer and implements the actual drawing API. This makes it easier to handle reference to target layers.

abey79 commented 1 year ago

Initial implementation in b5e49c2339a1c74158f42017bc31cad3d27513b1

abey79 commented 11 months ago

Much better take in the vsvg-sketch crate.