Open abey79 opened 1 year ago
I don't recall of a good reason to enforce strictly-positive layer ID, except 1-based numbering feeling more natural to non-tech users. On Rust side, it can be enforced with NonZeroUsize
, but it's annoying to use (NonZeroUsize::new(1).unwrap()
). Plus, it can lead to unexpected behaviour if a layer is explicitly numbered 0 by the user.
Moving on, I'm going to accept 0 as layer ID, and use the following heuristics:
For the time being, I'll use "first group of digit" rather "all digits" to extract a layer ID from
inkscape:label
orid
.
This doesn't solve all of the possible "WTF" behaviour, e.g. with layers named after colours such as "magenta90" and "orange90".
This particular case would be gracefully handled by the EMSL standard where only the starting group of digit is interpreted as layer ID, but any other group of digit is not.
I currently don't have a plan to revolutionise the way vpype identifies its layers: namely using a non-zero integer value, with higher-ID layers drawn on top of lower-ID layers.
vpype currently uses the following approach to determine layer IDs (from
vpype read --help
):However, the stripping non-digit character strategy has led to unexpected behaviour: https://github.com/abey79/vpype/issues/594. Further, EMSL introduced an informal spec on layer names here, which would be worth considering (especially for SVG output).
For the time being, I'll use "first group of digit" rather "all digits" to extract a layer ID from
inkscape:label
orid
.