Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document and give example of intermix of SimpInkScr and inkex #113

Open
robertlugg opened this issue Nov 7, 2023 · 3 comments
Open

Document and give example of intermix of SimpInkScr and inkex #113

robertlugg opened this issue Nov 7, 2023 · 3 comments

Comments

@robertlugg
Copy link

When I was looking into using the package I was worried that it was an either/or proposition to use traditional Extension programming or to use SimpInkScr. It would be nice to document the ability briefly. An example would also help to demonstrate. I don't know exactly how this should look but I was thinking of something like:

# Draw left circle using Simple Inkscape Scripting interface
style = {'stroke': '#000000', 'stroke-width': 1, 'fill': '#FF0000'}
circle((0, canvas.height/2), canvas.width/4, **style)

# Draw right circle using the inkex lower-level interface
style = {'stroke': '#000000', 'stroke-width': 1, 'fill': '#0000FF'}
parent =  extension.svg.get_current_layer ()
circle_attribs = {'style': str(inkex.Style(style)),
                    inkex.addNS('label', 'inkscape'): "mycircle",
                    'cx': str(canvas.width), 'cy': str(canvas.height/2),
                    'r': str(canvas.width/4)}
parent.add(inkex.Circle(**circle_attribs))

Code like this can be pasted directly into the "Python Code" dialog to demonstrate the two libraries working seamlessly together. I'm happy to make the changes but am not confidant that my code example is correct and best :)

@spakin
Copy link
Owner

spakin commented Nov 8, 2023

Your example is good in that it shows how to draw the same shape with both the high- and low-level interfaces. However, it leaves the reader wondering why one might want to use inkex directly. Can you think of a small example showing something that requires inkex?

I can imagine integrating this sort of documentation into the Advanced usage wiki page.

@WillAdams
Copy link

Alternately, perhaps SimpInkScr could have a mode (Log window?) where it could be used as a didactic tool?

Enter a simple command such as:

circle((0, canvas.height/2), canvas.width/4, **style)

and get back the inkex equivalent?

@spakin
Copy link
Owner

spakin commented Mar 21, 2024

That's an interesting idea, but I suspect it would require a lot of work, especially relative to its overall utility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants