Git Product home page Git Product logo

simpinkscr's Introduction

Simple Inkscape Scripting

Description

In the Inkscape vector-drawing program, how would you go about drawing 100 diamonds, each with a random color and placed at a random position on the page?

diamonds

Option 1: Draw, color, and place the diamonds manually. This is exceptionally tedious.

Option 2: Create an Inkscape extension to automate the process. This involves gaining familiarity with a large API and writing a substantial amount of setup code just to perform what ought to be a simple task.

Neither option is particularly enticing. This is why I created the Simple Inkscape Scripting extension for Inkscape. Simple Inkscape Scripting lets you create shapes in the current Inkscape canvas with a Python script plus a set of simple functions such as circle for drawing a circle and rect for drawing a rectangle. The picture shown above was created using just the following five lines of code:

for i in range(100):
    x, y = uniform(0, canvas.width), uniform(0, canvas.height)
    rect((-5, -5), (5, 5),
         transform='translate(%g, %g) scale(0.75, 1) rotate(45)' % (x, y),
         fill='#%02x%02x%02x' % (randrange(256), randrange(256), randrange(256)))

The first line is an ordinary Python for loop. The second line selects a position for the rectangle. Note that Simple Inkscape Scripting predefines canvas.width as the canvas width and canvas.height as the canvas height. The random package is imported into the current namespace so uniform can be invoked directly. The third line draws a 10×10 pixel rectangle centered on the origin. The fourth line rotates the rectangle by 45°, squeezes it horizontally into a lozenge, and moves it to the target position. The fifth line specifies a random fill color.

The diamonds drawn on the canvas are all ordinary Inkscape objects and can be further manipulated using any of the usual Inkscape tools.

In short, Simple Inkscape Scripting helps automate repetitive drawing tasks. Unlike writing a custom Inkscape extension, Simple Inkscape Scripting requires sufficiently little boilerplate code as to make its use worthwhile even for tasks that will be performed only once or twice.

Installation

First, identify your Inkscape extensions directory. This can be found in Inkscape's preferences: Go to EditPreferencesSystem and look in the User extensions field. On Linux, the extensions directory is typically $HOME/.config/inkscape/extensions/.

Second, install Simple Inkscape Scripting in that directory or any subdirectory. For example,

cd $HOME/.config/inkscape/extensions/
git clone https://github.com/spakin/SimpInkScr.git

will retrieve the code from GitHub. This later can be updated with

cd $HOME/.config/inkscape/extensions/SimpInkScr/
git pull

If Inkscape is already running, exit and restart it to make it look for new extensions.

Usage

Python code to Inkscape

Launch the Simple Inkscape Scripting extension from Inkscape via ExtensionsRenderSimple Inkscape Scripting…. This will bring up a dialog box that gives you the option to enter a filename for a Python program or enter Python code directly in a text box. These options are not mutually exclusive; if both are used, the Python code in the file will be executed first, followed by the Python code in the text box. This enables one, for example, to define functions in a file and invoke them with different parameters from the text box.

As an initial test, try entering

circle((100, 100), 50)

into the text box and clicking Apply then Close. This should create a black circle of radius 50 at position (100, 100).

Inkscape to Python code

Simple Inkscape Scripting can also save illustrations from the Inkscape GUI to a Python script that, when run from the Simple Inkscape Scripting extension, reproduces the original illustration. (Note, though, that not all Inkscape features are currently supported.) From FileSave a Copy…, simply select Simple Inkscape Scripting script (*.py) from the pull-down menu at the bottom of the dialog box. This can be useful, for instance, for manually drawing a complex object then using Simple Inkscape Scripting to replicate and transform it.

Documentation

Legal

Simple Inkscape Scripting is

Copyright © 2021–2023 Scott Pakin

All code is licensed under the GNU General Public License version 3. See the license file for details.

Author

Scott Pakin, [email protected]

simpinkscr's People

Contributors

bevsxyz avatar inter1965 avatar kantas-spike avatar remotedots avatar rmcginty avatar spakin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simpinkscr's Issues

Create new layer

Is it possible to create a new layer? If it is, I cannot figure out how to do so - at least not correctly.

The main wiki page states that "For example, the document as a whole can be read and modified via self.svg". However, when I try to access self.svg in a script (e.g. layer = self.svg.add(Group('New Layer Name', is_layer=True))), I get an exception: NameError: name 'self' is not defined

I had limited success with this:

layer = inkex.Layer.new('New Layer Name')
inkex_object(layer)

However, I can't then figure out how to add items to it. Any objects I create appear on the default layer, and I can't find a working way to move them to the new layer. Also, the new layer appears as a child of a new, unnamed layer - not at the top level of layers.

Add "anchor" argument to scale method

Similarly to the rotate method : rotate(angle, anchor, first) , the scale(factor, first) method should also accept an anchor.

Why:

Because if the scale is applied on the object multiple times, the object is moving and that's not necessarily the desired behaviour. So basically, scale should add anchor argument so the user could specify the center of the object to be used.

Steps to reproduce the reported bahaviour:

  • Draw an object, e.g. a rectangle and select it.
  • Run the following code:
objs = svg_root.selection

for obj in objs:
   obj = inkex_object(obj)
   obj.scale(1.2)

When you keep pressing "Apply" button, the objects get scaled but move also.

record

Error when trying to insert a newline character using `more_text` function

I am using the functions text and more_text to insert some text. I need to insert a newline as follows:

text('Hello, ', (width/2, height/2), font_size='24pt', text_anchor='middle')
more_text('Inkscape', font_weight='bold', fill='#800000')
more_text('!!!')
more_text('\n')
more_text('A new line')

But when I run that code, I get the following error:

<string> 4 
Error in sys.excepthook:
Traceback (most recent call last):
  File "/home/ajrou/.local/lib/python3.8/site-packages/pretty_errors/__init__.py", line 683, in excepthook
    writer.write_code(syntax_error_info[0], syntax_error_info[1], [], True, syntax_error_info[2])
  File "/home/ajrou/.local/lib/python3.8/site-packages/pretty_errors/__init__.py", line 572, in write_code
    while start_char > 0 and line[start_char - 1] not in (' ', '\t'):
IndexError: string index out of range

Original exception was:
Traceback (most recent call last):
  File "simple_inkscape_scripting.py", line 779, in <module>
    SimpleInkscapeScripting().run()
  File "/usr/share/inkscape/extensions/inkex/base.py", line 131, in run
    self.save_raw(self.effect())
  File "/usr/share/inkscape/extensions/inkex/extensions.py", line 193, in effect
    for child in fragment:
  File "simple_inkscape_scripting.py", line 773, in generate
    exec(code, sis_globals)
  File "<string>", line 4
    more_text('
              ^
SyntaxError: EOL while scanning string literal

Procedural generation via Inkscape's command line

Simple Inkscape Scripting offers a lot of amazing possibilities for procedural generation.

Right now however, it can be a bit cumbersome to always write Python code inside SIS's dialogue box (e.g. no syntax highlighting, potential indentation errors, etc) or having to click 'Apply' each time you write code outside of Inkscape.

At the moment, Inkscape already supports command line arguments. Is there a way that you can then generate and export/SVGs with Simple Inkscape Scripting through calls to Inkscape via the command line?

How to apply effects?

Hello Scott

Sorry to bother you again ... last question, I swear
What about effects, I mean inkscape:path-effect?
for example construct_grid effect?

How to rotate each selected object about its own rotation center

I am selecting multiple paths in the canvas and when I apply the rotation transform for each selection it seems that the objects are not rotating about their own rotation center.

objs = svg_root.selection
for obj in objs:
   obj.transform.add_rotation(30)

How can specify that each obj should its "own" rotation center for the rotation transform?

Many thanks

Examples for Exporting as animation

I look forward to see some examples that demonstrate the power of scripting to create some animations, such as SVG animations, or exporting shapes as png and using an external tool such as ImageMagick to create gif/video files

Thanks

Float object is not callable

Running from
Inkscape Appimage version Inkscape 1.1.2 (0a00cf5, 2022-02-04)

Installed by

cd
cd .config/inkscape/extension
git clone https://github.com/spakin/SimpInkScr.git

Trying to execute script :

numArms = 11
circle  = 2 * 3.14159265359
eachArm = circle / numArms
overlap = 0.10


    
center = (width/2, height/2)
radiusMain = 40

numCircles = 5
circleRadius = 20

for a in range(0,numArms) :
    theta = a*eachArm
    
    strt = theta - eachArm / 2 - eachArm*overlap
    stop = theta + eachArm / 2 + eachArm*overlap
    gaps = numCircles - 1
    gapWidth = (stop - strt ) / gaps
    for t in range(0,numCircles) :
        
        tt = strt + t * gapWidth
        
        x_circle_inArm = int(radiusMain * cos(tt) + center[0])
        y_circle_inArm = int(radiusMain * sin(tt) + center[1])
        circle((x_circle_inArm, y_circle_inArm), circleRadius)

Script up to the line circle((x_circle_inArm, y_circle_inArm), circleRadius) works.

Error
Traceback (most recent call last):
File "simple_inkscape_scripting.py", line 2103, in
SimpleInkscapeScripting().run()
File "/tmp/.mount_InkscaLQHf7h/usr/share/inkscape/extensions/inkex/base.py", line 131, in run
self.save_raw(self.effect())
File "simple_inkscape_scripting.py", line 2096, in effect
exec(code, sis_globals)
File "", line 32, in
TypeError: 'float' object is not callable

Expected behavior
Cirlces along a circular arc to be drawn on canvas

To reproduce :

  1. Install appimage of inkscape
  2. Install simple inkscape scripting from github as shown above
  3. Render > simple inkscape scripting
  4. Paste the code in the window
  5. Apply

PLEASE help

Bounding_box on images not returning image size

Fantastic extension. Really enjoying it and well documented. I'm trying to get the size of and image and the center of an image. The bounding _box feature is returning only the top left anchor point. Similar to text. Same when using clone. Is there another way to get image size info? I'm want to add borders around a mix of photos in a folder.

animation.py does not show any motion

I read the code but there are no instructions on how to actually
display the animation.
How does it work?

I saw the readme has links to docs so I will peruse that to
see what I can find and report back.

[Question]-- How to get the canvas size?

Greetings
I started today to play with the examples provided in this repository, and to be honest it's mind blowing ;)
I am reading the Wiki page to learn more about the available options/shapes, etc.

I wonder how can I access the Canvas size from within the extension?

I have tried:

canvas_width  = self.unittouu(svg.get('width'))
canvas_height = self.unittouu(svg.attrib['height'])

But it doesn't work.

  • Is there a proper way to get these info inside the extension?
  • How can I access the selected objects on the canvas?

Have a nice day

The dialog box cannot be resized!!

This issue is tested on Microsoft Win10,
with the screen resolution of 1920x1080,
with Inkscape 1.1 and many 1.2-devs.

The dialog box of "Simple Inkscape Scripting" cannot be resized,
so I cannot see the [Apply] button,
please check.

Thank you!

The rotate and scale with anchor set to "center" doesn't work for Polygons/Stars, Text, and spirals

Hello,
Sorry, if this doesn't deserve its own issue.

The new rotate and scale that accept anchor points work perfectly for different objects such as rectangles, circles, etc.

However, this doesn't seem to work for Polygons, Stars, text, or spirals.

How to reproduce:

  • Create a star (or an polygon, or a text or a spiral) and select it.
  • Run the code:
objs = svg_root.selection

for obj in objs:
   obj = inkex_object(obj)
   obj.scale(1.2, around='center')
   #obj.rotate(angle, around='center')

updated wiki animation example

Following your directions on how to use animation I created an update of the
web code with svg and gif.

Commit here: peterennis@0528fa6

  1. I used ScreenToGif to get a screen recording
  2. Page setup was added otherwise the animation would run from corner to corner in full screen
  3. Added the clear.py code to help with testing

How can I use parameters that will make a viewbox the size of the window
and mitigate screen resize issues?

crash loading new script

captured in file:

simp_ink_err.pdf

Steps:

  1. Load and run 100 shapes sample (Inkscape 1.1.1)
  2. Delete code and paste another example
  3. Run new code

Error.

Needs a button to clear the existing script ???

animation example not working

Using this code from the wiki:

Screenshot 2022-01-14 210607

Test case here: peterennis@9dc1d5a

I get a green box, no animation, and no feedback.

The other examples in the list are working. I commented them out
to show this issue. The intent is to run all the examples as one test
with adjusted begin times. I tried also with repeat count = 2

How would I go about debugging? Using print("here") does not provide
any useful data other than to show the interpreter has passed the
problem line.

set method fails silently when the value is numeric

When using set method to change the style of an object, e.g:

objs = svg_root.selection
for obj in objs:
   obj.set('width', 50) # <<<<<<< the value is numeric

When you run that, nothing changes. Instead the user need to explicitly to convert the value to a string, i.e.:

obj.set("width", str(50))

SimpIncScr should at least raise an error explictly when the value is numeric or convert it automatically.

Show an error message when there is no selected object but a layer

I am trying the recent API of SimpInkScr using Inkscape 1.2-dev:

objs = svg_root.selection

for obj in objs:
   obj = inkex_object(obj)
   obj.rotate(50, 'center')

The document is empty but I have selected the Layer 1 from "Object > Layer and objects" as shown below

image

But I am getting this confusing error message (I believe this could happen, if the layer is accidently selected intead of an object).

Is there an easy solution to get a meaninful error message to inform the user that the selection is a layer so it couldn't be transformed?

-------------------------------------------------------------------------------
simple_inkscape_scripting.py 1709 <module>
SimpleInkscapeScripting().run()

base.py 147 run
self.save_raw(self.effect())

simple_inkscape_scripting.py 1705 effect
exec(code, sis_globals)

<string> 4 <module>


simple_inkscape_scripting.py 1540 inkex_object
return SimpleObject(obj, merged_xform, conn_avoid, clip_path,

simple_inkscape_scripting.py 279 __init__
_simple_top.append_obj(self)

simple_inkscape_scripting.py 187 append_obj
self._svg_attach.append(obj._inkscape_obj)

etree.pyx 825 lxml.etree._Element.append


apihelpers.pxi 1341 lxml.etree._appendChild


ValueError:
cannot append parent to itself

integrate easing functions for animation

I found that Robert Penner's easing functions are a standard for simple animation.
A GPL v3 port to Python is found here:

https://github.com/semitable/easing-functions

Is it possible to use in SIS? I do not know enough Python yet to
deal with the integration.

e.g., I would like to extend your rectangle animation so that the boxes
bounce back and forth using one of these easing functions.

A more general question is how to integrate other Python libraries?

The default size of the window is small

Hi,
When I run the extension, the main window looks like this:

default

As you can see, the window is small and more particularly, the code area is very small and one needs every time he/she opens this extension to resize the window. So every time I open the extension I need to resize the window to something like this:

after_resize

I hope this gets fixed.

Thank you

TypeError: 'SimpleObject' object is not iterable

Screenshot 2022-01-15 135537

This commit: peterennis@994af70

Traceback (most recent call last):
  File "C:\Users\peter\AppData\Roaming\inkscape\extensions\SimpInkScr\simple_inkscape_scripting.py", line 1545, in <module>
    SimpleInkscapeScripting().run()
  File "C:\Program Files\Inkscape\share\inkscape\extensions\inkex\base.py", line 131, in run
    self.save_raw(self.effect())
  File "C:\Users\peter\AppData\Roaming\inkscape\extensions\SimpInkScr\simple_inkscape_scripting.py", line 1541, in effect
    exec(code, sis_globals)
  File "<string>", line 28, in <module>
  File "C:\Users\peter\AppData\Roaming\inkscape\extensions\SimpInkScr\simple_inkscape_scripting.py", line 689, in animate
    self._animate_transforms(all_iobjs, duration,
  File "C:\Users\peter\AppData\Roaming\inkscape\extensions\SimpInkScr\simple_inkscape_scripting.py", line 529, in _animate_transforms
    target = group(target)
  File "C:\Users\peter\AppData\Roaming\inkscape\extensions\SimpInkScr\simple_inkscape_scripting.py", line 1335, in group
    for o in objs:
TypeError: 'SimpleObject' object is not iterable

SVG previews for example scripts

Hi,

It would be nice if we could add SVG files into the repo, showing how each example script's render would look like. Then we could also link the preview to the example list.

Perhaps I could try and raise a pull request. Any thoughts?

a lot of blinking during animation creation

This code:

r01 = rect((0, 0), (32, 0), stroke='#2b1100', fill='#ff0000', font_variation_settings='normal', opacity=1, vector_effect='none', fill_opacity=1, fill_rule='evenodd', stroke_width=1, stroke_linecap='butt', stroke_linejoin='miter', stroke_miterlimit=4, stroke_dasharray='none', stroke_dashoffset=0, stroke_opacity=1, _inkscape_stroke='none', stop_color='#000000', stop_opacity=1)
r1 = rect((0, 0), (32, 1024), stroke='#2b1100', fill='#ff0000', font_variation_settings='normal', opacity=1, vector_effect='none', fill_opacity=1, fill_rule='evenodd', stroke_width=1, stroke_linecap='butt', stroke_linejoin='miter', stroke_miterlimit=4, stroke_dasharray='none', stroke_dashoffset=0, stroke_opacity=1, _inkscape_stroke='none', stop_color='#000000', stop_opacity=1)
r01.animate([r1], duration='2s')

r02 = rect((1024, 32), (1024, 0), stroke='#2b1100', fill='#ff0000', font_variation_settings='normal', opacity=1, vector_effect='none', fill_opacity=1, fill_rule='evenodd', stroke_width=1, stroke_linecap='butt', stroke_linejoin='miter', stroke_miterlimit=4, stroke_dasharray='none', stroke_dashoffset=0, stroke_opacity=1, _inkscape_stroke='none', stop_color='#000000', stop_opacity=1)
r2 = rect((0, 0), (1024, 32), stroke='#2b1100', fill='#ffff00', font_variation_settings='normal', opacity=1, vector_effect='none', fill_opacity=1, fill_rule='evenodd', stroke_width=1, stroke_linecap='butt', stroke_linejoin='miter', stroke_miterlimit=4, stroke_dasharray='none', stroke_dashoffset=0, stroke_opacity=1, _inkscape_stroke='none', stop_color='#000000', stop_opacity=1)
r02.animate([r2], duration='2s', begin_time='2s',)

This blinking:

Blinking

This svg animation result:

rectangles-animation2

  1. Is the blinking expected? It gets longer as the animation increases.
  2. Can it be reduced? Replaced with a progress bar? Just use ........ progress instead?
  3. How can I do something similar to:
    r02 = rect((1024, 32), (1024, 0), f(get-the-settings())
    where get-the-settings returns the string of values?

Reversing a path connects gaps

I can create a path with a gap in it like so:

path_1 = path([Move(64, 64), Line(64, 128), Move(64, 196), Line(64, 256)])

If I reverse such a path, it no longer has a gap:

path_2 = path([Move(128, 64), Line(128, 128), Move(128, 196), Line(128, 256)])
path_2.reverse()

How can I reverse a path but preserve the gap?

Here is a screenshot of the result of those two snippets:
path_and_reversed_path

Thank you for a sweet API!

Installation test of circle((100, 100), 50) fails

Installing into the following directory: C:\Program Files\Inkscape\share\inkscape\extensions\SimpInkScr
and then running circle((100, 100), 50) leads to the following error:
Traceback (most recent call last): File "C:\Program Files\Inkscape\share\inkscape\extensions\SimpInkScr\simple_inkscape_scripting.py", line 739, in <module> SimpleInkscapeScripting().run() File "C:\Program Files\Inkscape\share\inkscape\extensions\inkex\base.py", line 131, in run self.save_raw(self.effect()) File "C:\Program Files\Inkscape\share\inkscape\extensions\inkex\extensions.py", line 193, in effect for child in fragment: File "C:\Program Files\Inkscape\share\inkscape\extensions\SimpInkScr\simple_inkscape_scripting.py", line 725, in generate if py_source != '' and not os.path.isdir(py_source): File "C:\Program Files\Inkscape\lib\python3.9\genericpath.py", line 42, in isdir st = os.stat(s) TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

How to automate the creation of guides

Thank for such great extension! I would like to automate the tedious work of creating guides. I usually create the same guides, at 10% of the size, plus 13% bottom margin and a final guide at 7% height.
Is there a function to create guides? I couldn't find in the documentation.

Inkscape crashes with connector avoidance example when ungrouping the results

I have tried the example of connector avoidance: https://github.com/spakin/SimpInkScr/wiki#connector-avoidance

r1 = rect((100, 0), (150, 50), fill='#fff6d5')
r2 = rect((200, 400), (250, 450), fill='#fff6d5')
connector(r1, r2, ctype='orthogonal', curve=100)
circle((225, 225), 25, fill='red', conn_avoid=True)

It produces the shape without issues, but when I select the result and press Shift Ctrl G to ungroup it, Inkscape crashes

crash

I am using:

Inkscape 1.1.1 (1:1.1+202109281949+c3084ef5ed)

    GLib version:     2.64.6
    GTK version:      3.24.20
    glibmm version:   2.64.2
    gtkmm version:    3.24.2
    libxml2 version:  2.9.10
    libxslt version:  1.1.34
    Cairo version:    1.16.0
    Pango version:    1.44.7
    HarfBuzz version: 2.6.4
    Poppler version:  0.86.1

    OS version:       Ubuntu 20.04.3 LTS

Feature Request; Flip Object

Would you be able to add the ability to flip the selected object? I am currently flipping both vertically and horizontally each text box in a drawing I am working on. I am talking about around 200+ text boxes.

speedometer demo looks strange

  1. Load speedometer, Apply
  2. It looks strange, so I added a new layer below with a yellow box to view it
  3. Ticks are not line ticks

Screenshot 2021-12-31 200348

I changed some code parameters and can get this result:

Screenshot 2021-12-31 202308

Commit here: peterennis@324d0e3

Saving Script Output To SVG

Thanks for such a lovely extension I'm having a great time with it!

I'm using it to generate electronic diagrams and would like to save the generated graphic to an SVG file.

I've been exploring with trying to get the svg structure out using the svg_root global variable but haven't been able to quite crack it.

Is this possible, or planned functionality in the future?

Getting an error when using text function

I have copied the following sample code from the Wiki:

text('Hello, ', (width/2, height/2), font_size='24pt', text_anchor='middle')
more_text('Inkscape', font_weight='bold', fill='#800000')
more_text('!!!')

When I run it, I get:

simple_inkscape_scripting.py:1124: DeprecationWarning: inkex.deprecated.width -> Use BaseElement.viewport_width instead
  sis_globals['width'] = self.svg.width
simple_inkscape_scripting.py:1125: DeprecationWarning: inkex.deprecated.height -> Use BaseElement.viewport_height instead
  sis_globals['height'] = self.svg.height

-------------------------------------------------------------------------------
simple_inkscape_scripting.py 1153 <module>
SimpleInkscapeScripting().run()

base.py 147 run
self.save_raw(self.effect())

extensions.py 194 effect
for child in fragment:

simple_inkscape_scripting.py 1136 generate
if py_source != '' and not os.path.isdir(py_source):

genericpath.py 42 isdir
st = os.stat(s)

TypeError:
stat: path should be string, bytes, os.PathLike or integer, not NoneType

(or see the screenshot below)

image

Inkscape version

Inkscape 1.2-dev (b4ff126, 2022-01-02)

    GLib version:     2.64.6
    GTK version:      3.24.20
    glibmm version:   2.64.2
    gtkmm version:    3.24.2
    libxml2 version:  2.9.10
    libxslt version:  1.1.34
    Cairo version:    1.16.0
    Pango version:    1.44.7
    HarfBuzz version: 2.6.4

    OS version:       Ubuntu 20.04.3 LTS

Extend SimpInkScr to create arcs

I'm building several simulated flight instruments and will be using .svg to represent the faces of dials in an aircraft. These include various markings distributed around an arc, as well as colored arcs of multiple lengths.

If I can do this with the current SimpInkScr, I'd like to learn how and add documentation to the .md file. If an additional function is needed, I'd like to learn to code it to be included in the SimpInkScr library, either locally, as part of your library.

        arc( outside_dia, inside_dia, start_angle, end_angle,color).

The second type of arc would place a rotated rectangular shape, similar to the markings on a clock face.

I want to write a second function that may be added directly to the library or given as an example:

       radial_marks(length, width, start_angle, end_angle, angle_incr, color)

The immediate goal is to produce items like this:

image

Adding unit tests?

Hi,
Are there any plans to use unit tests and CI (github actions) for SimpInkScr?

This could make the developement and maintenance for several inkscape versions easier.

Thanks

Installation under Windows not working

Hello, sorry if this is a no-brainer, but I'm having trouble to get this extension running under Windows.

Environment:

  • Windows 10 Pro 21H1, 64-Bit
  • Inkscape v1.2 (dc2aedaf03, 2022-05-15) (Windows 64-Bit)

Steps to reproduce the bug:

  1. Install Inkscape v1.2 (dc2aedaf03, 2022-05-15) for Windows via .exe: https://inkscape.org/release/1.2/windows/64-bit/.
  2. Downloaded the lastest release (v3.1.0) of this extension.
  3. Unzip the archive to get the folder simple_inkscape_scripting.
  4. Copy the folder simple_inkscape_scripting to C:\Program Files\Inkscape\share\inkscape\extensions.
  5. Start Inkscape via C:\Program Files\Inkscape\bin\inkscape.exe.
  6. Open a new document via "New Document".
  7. Start the extension via Menubar --> Extensions --> Render --> Simple Inkscape Scripting...
  8. Insert a simple example script into the field "Python code":
    for i in range(10, 0, -1):
        ellipse((width/2, height/2), (i*30, i*20 + 10),
                fill='#0000%02x' % (255 - 255*i//10), stroke='white')
  9. Click on "Apply".
  10. A modal "'Simple Inkscape Scripting' working, please wait...' is opened.
  11. Immediately after, an error modal is opened:

    Inkscape has received additional data from the script executed. The script did not return an error, but this may indicate the results will not be as expected.

    C:\Program Files\Inkscape\bin\pythonw.exe: can't find '__main__' module in 'C:\\Program Files\\Inkscape'
    

By the way, I have two entries "Simple Inkscape Scripting..." under "Extensions". I assume this is not intentional, but both commands behave exactly the same and there is no second simple_inkscape_scripting folder in my extensions folder.

Any help would be appreciated!

Exporting as .py file is not documented

Description:

Exporting as "Simple Inkscape Scripting Script" is not documented

Steps to reproduce:

  • Open inkscape
  • Draw something
  • File > Save and choose "Simple Inkscape Scripting Script" then click save
    image

What happens:

  • It saves a python file and user is confused

What do you expect:

  • User expect some documentation about this functionality and know the limitations of it.

Additional Informations:

  • Not specific to any platform

Record the GUI actions into a python file

Hello,

I just discovered your extension via inklinea.
Many thanks for developing it !

I was wondering if it is planned to do the opposite workflow in SimpInkScr: trace/record the actions made in the GUI to tangle them in a python file for later modification and execution with different parameters for example ?

If I understand the current workflow, the way it is implemented is from the python script to the GUI.
Is this correct ?

Anyway, many thanks for this extension, IMHO it was missing in the Inkscape ecosystem in my opinion.
THANKS !

wiki demos hard to see in Github dark mode

I tested default light and dark modes as well as enhanced light and dark modes.
The graphics shown are not good for dark mode. They would be better with a white
background. This appears to be a problem for all the graphics.

Screenshot 2022-02-06 150222

Screenshot 2022-02-06 150609

licensing question

SIS is GPL v3+

This is fine, but it seems to me that using a simple script such as Clear.py (https://github.com/peterennis/SimpInkScr/blob/Synkypy/aepyx/002_Clear.py)
introduces copyleft with a sledgehammer.

I did some research on Python licensing here: https://docs.python.org/3/license.html

The relevant part is:

Terms and conditions for accessing or otherwise using Python
Python software and documentation are licensed under the PSF License Agreement.

Starting with Python 3.8.6, examples, recipes, and other code in the documentation are dual licensed under the PSF License Agreement and the Zero-Clause BSD license.

While learning Python and SIS it is not clear to me the licensing terms of the wiki examples.

I have some animations here: https://adaept.com/menu/home
and here: https://adaept.com/menu/logae
and here: https://adaept.com/menu/kute

I would like to port some of them to SIS SMIL but remain hesitant
due to the implicit GPL v3+ wiki license.

Please provide some clarification.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.