nornagon / saxi

Tools & library for driving the AxiDraw pen plotter
GNU Affero General Public License v3.0
471 stars 55 forks source link

Saxi doesn't recognise some multi-layer files #40

Closed abey79 closed 4 years ago

abey79 commented 4 years ago

I have an example of multi-layer SVG file for which SAXI will not show the layer selector. How can I plot a single layer of this file?

Here is the file: patterns_8x.svg.zip

nornagon commented 4 years ago

Saxi uses stroke color, not svg layers (groups) to split layers apart. Try making each layer a different stroke color?

abey79 commented 4 years ago

Oh ok. Thanks for the quick answer -- this solves my immediate issue. That said, I will have to vary layer colours in vpype's export so make its output directly compatible with saxi. Is colour the only attribute that's being considered or are there others? Is it ok if colour is set at group level (as opposed to individual path?

nornagon commented 4 years ago

yep, setting the stroke color on the group works since saxi v0.8.1.

nornagon commented 4 years ago

Spent some time thinking about this tonight. I'm uncertain how to handle the two separate modes of layering, here are some possibilities:

  1. Stop supporting layer-by-stroke, switch to layer-by-group-id completely. Layer-by-stroke is a bit of a hack anyway.
  2. Detect whether there exists a <g id="..."> anywhere in the SVG, and if so, use layer-by-group-id. Otherwise, use layer-by-stroke.
  3. The inverse of (2), use layer-by-group-id when layer-by-stroke would produce exactly 1 layer (i.e. there are no stroke-separated layers).
  4. Allow toggling between grouping modes in the UI.

Currently I'm tending towards (3), since it doesn't break any existing usage, though it might be good to have an override. Perhaps if it detects that either stroke-based or <g>-based methods would both produce >1 layer, it could allow toggling between them?

[edit] another possibility would be to have both group ID and stroke combine to form layer ID. So every unique combo of group + stroke could be a unique layer. or allow stroke and group to be "orthogonal" layerings, so you could choose a set of group ids and separately choose a set of stroke colors, and the plotted paths would be only those paths which are in a selected group AND in a selected stroke. that's probably overly complex, though.

nornagon commented 4 years ago

Give 0.9.0 a whirl, I went with (3) + (4) :)

abey79 commented 4 years ago

Looks great, will try it out ASAP. Thanks for taking the time!