Script for splitting layers in an Inkscape SVG #701
Replies: 5 comments 2 replies
-
|
Wow, very nice example and challenge! As I responded in PR ... I also think positional Attr? doesn't make that much sense. For such cases (unknown attributes) Attrs? would make sense, to get all of them. I see I already have Attr? by name in html dialect (builtins_html.go), which is very similar dialect. I will upgrade the sxml with your changes and add this and go through your observations and questions. Great! |
Beta Was this translation helpful? Give feedback.
-
|
I did some improvements you proposed, will push online. This is the current state. I will still work on this ... it's a great example that exposed many things. |
Beta Was this translation helpful? Give feedback.
-
|
@lluchs I'm looking at the code and I'm again impressed, how you are able to use (and implement or fix - cmd sxml) very specific features of Rye. Like BTW: I posted this example on reddit |
Beta Was this translation helpful? Give feedback.
-
|
You mean the ref/deref and a consequent crash ... for most of Rye dev I didn't need mutable objects. When I hit this wall I decided for this mechanism, but I haven't really had time yet to think about it deeply. So this is still "open design" issue. But I think we can certanly make it not crash rye. It could return an error if function is expecting derefed value and it got ref and vice versa, another option is taht functions accept both or ref/deref themselves. Frankly ... I'm not sure what is better language-wise at this point also. We need to work with this some more I think. But I will work to make it stabile as it is now. The collector idea now works. Your cool example just keeps on producing new features :) . Something like this used to be hardcoded into function context which was bad and made them heavier. Now it's just specific Rye context and a function. Thanks! |
Beta Was this translation helpful? Give feedback.
-
|
Yes, in general or at first all Rye values were non-pointers. But to modify a value in-place ... for example with append! you need to use a pointer. So ref / deref was added for these cases. Ref basically just returns a pointer of a value, and deref returns a value of a pointer. I have too many things open right now, and no real vision into this so this will stay for now. But making Rye not crash, but return sensible error with ref will be done. I like the code too, it has a "flow" and uses full Rye ... you created a nice versatile problem to think about :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Here's another script I wrote and some observations. The script takes an SVG file created with Inkscape and then outputs one SVG for every layer in the original file, with just that layer visible. It obviously requires #700 to work.
Here are my observations or questions:
attr?returns void is quite tricky. Is there a better way than what I found (while { tag .attr? i |type? = 'void |not })?do-sxmlis pretty neat, but then working with XML attributes is not nice at all.derefindict deref pairs, you get a panic.Beta Was this translation helpful? Give feedback.
All reactions