Simple Inkscape Scripting

Overview

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, width), uniform(0, 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 width as the canvas width and 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

Getting started

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). Due to how "generate extensions" work, Inkscape always places the output of Simple Inkscape Scripting within a group so ungroup it if desired.

See the examples directory for a collection of examples that can be run from the Simple Inkscape Scripting dialog box.

Shape API

All of the following functions return a Simple Inkscape Scripting object, which can be passed to the connector and group functions.

  • circle((cx, cy), r)

Draw a circle with center (cx, cy) and radius r. Example: circle((width/2, height/2), 50)

  • ellipse((cx. cy), rx, ry)

Draw an ellipse with center (cx, cy) and radii rx and ry. Example: ellipse((width/2, height/2), 75, 50)

  • rect((x1, y1), (x2, y2))

Draw a rectangle from (x1, y1) to (x2, y2). Example: rect((width/2 - 50, height/2 - 30), (width/2 + 50, height/2 + 30))

  • line((x1, y1), (x2, y2))

Draw a line from (x1, y1) to (x2, y2). Example: line((width, 0), (0, height))

  • polyline((x1, y1), (x2, y2), …, (xn, yn))

Draw a polyline (open polygon) from the given coordinates. Example: polyline((0, 300), (150, 0), (300, 300), (150, 200))

  • polygon((x1, y1), (x2, y2), …, (xn, yn))

Draw an arbitrary polygon from the given coordinates. Example: polygon((0, 300), (150, 0), (300, 300), (150, 200), fill='none')

  • regular_polygon(sides, (cx, cy), r, ang, round, random)

Draw a sides-sided regular polygon centered at (cx, cy) with radius r. All of the remaining arguments are optional. ang is the initial angle in radians and default to −𝜋/2 (upwards). round specifies how much to round the corners and defaults to 0.0 (sharp). random adds an amount of randomness to all vertex coordinates (default 0.0). Example: regular_polygon(5, (100, 100), 80)

  • star(sides, (cx, cy), (rt, rb), (angt, angb), round, random)

Draw a sides-sided star centered at (cx, cy) with tip radius rt and base radius rb. All of the remaining arguments are optional. angt and angb are the tip and base angles in radians and default to angles that do not skew the star and that point it upwards. round specifies how much to round the corners and defaults to 0.0 (sharp). random adds an amount of randomness to all vertex coordinates (default 0.0). Example: star(5, (100, 100), (80, 30))

  • path(elt, …)

Draw a path from a list of path commands (strings) and arguments (floats). Example: path('M', 226, 34, 'V', 237, 'L', 32, 185, 'C', 32, 185, 45, -9, 226, 34, 'Z')

  • connector(obj1, obj2, ctype, curve)

Draw a path that routes automatically between two Simple Inkscape Scripting objects. (All functions in the shape API return such an object.) ctype specifies the connector type and must be either polyline (any angle, the default) or orthogonal (only 90° bends). curve specifies the curvature amount (default 0). Example: r = rect((50, 50), (100, 100)); c = circle((200, 200), 25); connector(r, c, ctype='orthogonal', curve=15)

  • text(msg, (x, y))

Draw a piece of text starting at (x, y). Example: text('Simple Inkscape Scripting', (0, height), font_size='36pt')

  • more_text(msg, (x, y))

Append to a previous piece of text (created with text or more_text), possibly changing the style. The starting coordinates (x, y) are optional and can be used, e.g., to begin a new line. Example: text('Hello, ', (width/2, height/2), font_size='24pt', text_anchor='middle'); more_text('Inkscape', font_weight='bold', fill='#800000'); more_text('!!!')

  • image(fname, (x, y), embed)

Include an image. fname is the name of the file to include. A variety of image formats are supported, but only PNG, JPEG, and SVG are guaranteed to be supported by all SVG viewers. The upper-left corner of the image will lie at coordinates (x, y). If embed is True (the default), the image data will be embedded in the SVG file. This results in a larger SVG file, but it can be viewed without access to the original image file. If embed is False, the SVG file will merely reference the named file. This results in a smaller SVG file, but it requires access to the image file. If the image file is moved or deleted, it will no longer appear in the SVG file. fname can be a URL. In this case, embed must be set to False. Example: image('https://media.inkscape.org/static/images/inkscape-logo.png', (0, 0), embed=False)

  • clone(obj)

Return a linked clone of an object. Modifications made in the Inkscape GUI to the original object propagate to all clones. (This applies only to certain modifications such as rotations, style properties, and path control-point locations.) Example: r1 = rect((100, 100), (200, 200), fill='#668000') r2 = clone(r1, transform='translate(200, 0)')

Transformations

All of the functions presented under Shape API accept an additional transform parameter. transform takes a string representing an SVG transform (rotate, scale, etc.) and applies that transform to the object.

A shortcut for applying the same transformation to multiple objects is to invoke

  • transform(t)

This sets the default transformation to the string t. Objects specifying a transform parameter will prepend their transformations to the default (i.e., apply them afterwards).

Example:

transform('translate(100, 200) skewX(-15)')
for i in range(5):
    rect((i*100 + 10, 10), (i*100 + 40, 40))
    circle((i*100 + 75, 25), 15)

The above draws the shapes using coordinates near the origin then applies a transform to shift them to (100, 200). The transform also skews all the shapes to the right by 15°.

Connector avoidance

All of the functions presented under Shape API accept an additional conn_avoid parameter. conn_avoid takes a Boolean argument. If True, connectors created with connector will route around the shape. If False (the default), connectors will ignore the shape and route through it.

Example:

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)

Styles

Trailing key=value arguments passed to any of the functions presented under Shape API are treated as style parameters. Use _ instead of - in key. For example, write stroke_width=2 to represent the SVG style stroke-width:2.)

A shortcut for applying the same style to multiple objects is to invoke

  • style(key=value, …)

This augments the default style with the given parameters. Use a value of None to remove the default value for key. Objects specifying key=value style parameters override any default value for the corresponding key. Here, too, a value of None cancels the effect of a previously assigned key.

The default style for most shapes is stroke='black', fill='none'. Text has an empty default, which SVG interprets as stroke='none', fill='black'.

Example:

style(stroke='red', stroke_width=2, stroke_dasharray='5,5')
cx, cy = width/2, height/2
for d in range(200, 20, -20):
    gray = 255 - int(d*255/200)
    shade = '#%02x%02x%02x' % (gray, gray, gray)
    rect((cx - d, cy - d), (cx + d, cy + d), fill=shade)

In the above, the stroke style is set once and inherited by all of the rectangles, which specify only a fill color.

Groups

Due to how "generate extensions" work, Inkscape always places the output of Simple Inkscape Scripting within a group. It is possible to specify additional levels of grouping using

  • group(objs)

where objs is a list of initial objects in the group and is allowed to be empty. Like all of the objects in the shape API, group accepts optional transform, conn_avoid, and key=value style parameters.

Additional objects can be added to a group one-by-one by invoking the add method on the object returned by a call to group and passing it an object to add. Groups are themselves objects and can be added to other groups.

Example:

rad = 25
evens = group()
odds = group()
fills = ['cyan', 'yellow']
for i in range(8):
    sides = i + 3
    p = regular_polygon(sides, (i*rad*3 + rad*2, 3*rad), rad, fill=fills[i%2])
    if sides%2 == 0:
        evens.add(p)
    else:
        odds.add(p)

The preceding example draws regular polygons of an increasing number of sides. All polygons with an even number of sides are grouped together, and all polygons with an odd number of sides are grouped together. (Because all Simple Inkscape Scripting output is put in a single top-level group, you will need to ungroup once to access the separate even/odd-side groups.)

Additional convenience features

The document's width and height are provided in pre-defined variables:

  • width
  • height

print is redefined to invoke inkex.utils.debug, which presents its output within a dialog box after the script completes.

Because they are likely to be used quite frequently for drawing repetitive objects, Simple Inkscape Scripting imports Python's math and random packages into the program's namespace with

from math import *
from random import *

Hence, programs can invoke functions such as cos(rad) and uniform(a, b) and constants such as pi without having to import any packages or prefix those names with their package name.

Advanced usage

Because the Python code is invoked from within an Inkscape GenerateExtension object's generate method, it is possible to invoke functions from Inkscape's core API. For example, the document as a whole can be read and modified via self.svg, just as in a conventionally developed generate extension.

Objects created directly using Inkscape's core API should be made available to Simple Inkscape Scripting by passing them to the inkex_object function:

  • inkex_object(iobj)

Example: c = inkex.Circle(cx="200", cy="200", r="50"); inkex_object(c)

Author

Scott Pakin, [email protected]

Comments
  • error on my mac while running the simple circle example

    error on my mac while running the simple circle example

    I get this error message: (extensions folder is on chmod 755)

    Traceback (most recent call last): File "simple_inkscape_scripting.py", line 24, in import PIL.Image ModuleNotFoundError: No module named 'PIL'

    opened by InesSchneiderOAL 31
  • How to rotate each selected object about its own rotation center

    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

    opened by OpenFoam-User 15
  • The rotate and scale with anchor set to

    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')
    
    
    opened by OpenFoam-User 14
  • crash loading new script

    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 ???

    opened by peterennis 12
  • can´t do path union / intersection / exclusion

    can´t do path union / intersection / exclusion

    Hello, maybe I miss something obvious but i parsed all example and found this example: https://github.com/spakin/SimpInkScr/blob/master/examples/holes.py makes what Inkscape calls path difference,

    but i cannot find a way to do the other boolean path operations. I wonder if just an example is missing, or if i missed something obvious ?

    opened by pak-man 8
  • Show an error message when there is no selected object but a layer

    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
    
    opened by OpenFoam-User 7
  • Installation under Windows not working

    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!

    opened by lukassemmler 5
  • fix viewbox for turtle_spiral

    fix viewbox for turtle_spiral

    Loading the example with my inkscape settings does not show a result without zoom.

    Screenshot 2022-01-01 162520

    Add viewbox gives this result.

    Screenshot 2022-01-01 162826

    Commit here: https://github.com/peterennis/SimpInkScr/commit/709c4628c8e3f97f311823bec2db5d1152426a7d

    Should this be made consistent for demos?

    opened by peterennis 5
  • Is there a way to Union?

    Is there a way to Union?

    Hi, I was trying to union 2 rect's with this extension and I don't see any command for that.

    I know I can do it manually selecting both objects and going Path->union. Is that something we can do with the extension right now?

    opened by williamsokol 4
  • at_end=True  in animate gives error

    at_end=True in animate gives error

    e.animate([e1,e2, e3, e4], duration=secs, begin_time=beg, key_times=[0.0, 0.0, 0.5, 0.75, 1.0], at_end=True)

    line 882, in animate anim.set('values', '; '.join(vs)) TypeError: sequence item 4: expected str instance, NoneType found

    opened by gavytron 4
  • fix: font_family

    fix: font_family

    Comic Sans MS is not suitable for SVG files on the web. Hence using cursive instead is better for the web.

    Another option is to supply multiple font families as suggested here https://stackoverflow.com/a/21335048 This would require allowing the text function to take font_family as a string or a list based on context.

    opened by bevsxyz 4
  • SVG previews for example scripts

    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?

    opened by bevsxyz 3
Releases(v3.2.0)
  • v3.2.0(Dec 15, 2022)

    Here's what's noteworthy in this release of Simple Inkscape Scripting:

    • accurate bounding-box calculations for text and images,
    • support by all shape constructors for applying a transparency mask,
    • the ability to remove and group SVG objects converted to Simple Inkscape Scripting objects with all_shapes, selected_shapes, or inkex_object,
    • an auto_region parameter to filter_effect that selects between automatic and manually specified filter regions,
    • code restructuring to support Visual Studio Code integration (see #55),
    • improved compatibility across past, current, and forthcoming versions of Inkscape, and
    • multiple code improvements and bug fixes.

    See the Simple Inkscape Scripting commit log for details of all of the above.

    Source code(tar.gz)
    Source code(zip)
    simple_inkscape_scripting.zip(65.58 KB)
  • v3.1.0(Mar 16, 2022)

  • v3.0.0(Jan 30, 2022)

    This is a long overdue, major release of Simple Inkscape Scripting. It includes a large number of changes, a few of which are breaking changes and may require modifications to existing scripts.

    • The extension is now compatible with Inkscape 1.2-dev.

    • The text_path.py example no longer includes UTF-8-encoded characters because these confuse Windows, which expects Windows-1252 or some other non-standard encoding.

    • Objects can be removed by invoking their remove method (analogous to Inkscape's EditDelete).

    • Objects can be ungrouped by invoking ungroup on their containing group (analogous to Inkscape's ObjectUngroup).

    • Shape objects provide a to_path method that converts them to a path (analogous to Inkscape's PathObject to Path).

    • Simple Inkscape Scripting objects provide a get_inkex_object method that returns the underlying inkex object, which can be used for low-level SVG manipulation.

    • A duplicate method creates an independent copy of an object (analogous to Inkscape's EditDuplicate).

    • push_defaults and pop_defaults methods save and restore the current default transform and style.

    • A shape's style can be read and modified via the style method.

    • Inkscape live path effects (LPEs) can be instantiated using the path_effect function and applied to a path using the apply_path_effect method.

    • Objects created by Simple Inkscape Scripting no longer are grouped automatically but rather are applied individually to the canvas as one would expect.

    • Existing objects can more easily be modified using transform, rotate, scale, and skew methods.

    • For debugging, an svg method returns an object's underlying SVG code as a string.

    • Filters (analogous to Inkscape's Filters) can be created using the filter_effect function and applied to an object using its filter attribute.

    • Paths can be reversed using the reverse method (analogous to Inkscape's PathReverse).

    • Paths can be appended using the append method, which can be used for cutting holes in closed paths.

    • Objects can be reordered within their group or layer by invoking their z_order method (analogous to Inkscape's ObjectRaise to Top, Raise, Lower, and Lower to Bottom).

    • An object's underlying SVG element's tag (e.g., circle or g or image) can be retrieved using the tag method.

    • Attributes of an underlying SVG object can be read with the svg_get and written with the svg_set method.

    • Existing shapes on a canvas can be retrieved using the all_shapes and selected_shapes functions.

    • A number of unit tests are defined and scheduled to run automatically via GitHub Actions on each push to the repository.

    • The more_text function has been replaced by an add_text method on text objects.

    Source code(tar.gz)
    Source code(zip)
    simple_inkscape_scripting.zip(61.12 KB)
  • v2.1.0(Dec 19, 2021)

    Simple Inkscape Scripting has added a lot of nice, new features since the previous release. Here's what you can look forward to if you upgrade:

    • Clipping paths can be applied to objects.

    • Transformations can be applied/modified after object creation.

    • Objects can be animated. (Inkscape doesn't display SVG animations, but most Web browsers do.)

    • Objects can be converted to definitions. This is useful for creating template objects then instantiating (cloning) them with different transformations applied.

    • Markers (e.g., arrowheads) can be created and applied to paths.

    • Objects can be made into hyperlinks that can be followed when the SVG image is viewed in a Web browser.

    • Pre-defined conversion constants px, mm, cm, pt, and inch are provided to facilitate the use of absolute sizes and distances.

    Source code(tar.gz)
    Source code(zip)
    simple_inkscape_scripting.zip(49.55 KB)
  • v2.0.0(Dec 5, 2021)

    This is a major new release of Simple Inkscape Scripting. You'll definitely want to upgrade to pick up all the exciting new features!

    Breaking API changes

    The API has been made more consistent in terms of scalar versus tuple/list arguments. Items serving the same purpose are now consistently 2-tuples (for two of the same item) or lists (for varying numbers of items). For example, x and y radii are now specified as a single tuple, and lists of coordinates are now specified as a list rather than as an arbitrary number of individual arguments. These changes affect, in particular, ellipse, polyline, polygon, arc, and path. Please update your existing Simple Inkscape Scripting scripts accordingly.

    For convenience, arc accepts a scalar radius as a shorthand for a tuple containing two of the same radii; and path can accept a single string in addition to a list of terms, as the former may be helpful when copying and pasting from an existing SVG path string.

    Other improvements

    There are a lot these. Look at all the good things you get when you upgrade to Simple Inkscape Scripting v2.0.0:

    • The distribution includes an output extension that lets you save an SVG image as a Simple Inkscape Scripting script. Go to FileSave a Copy… and select Simple Inkscape Scripting script (*.py) from the pull-down menu.

    • SVG filter effects can be defined using the new filter function.

    • All Simple Inkscape Scripting shape objects provide a new bounding_box method.

    • rect can additionally draw rounded rectangles.

    • Simple Inkscape Scripting objects define a Python __str__ method that converts them to a string of the form url(#object-id). This enables them to be used as style values (which are automatically converted to strings). For example, text can be flowed into a frame with shape_inside=frame object.

    • text accepts an optional path argument that typesets the text along a path.

    • New linear_gradient and radial_gradient functions (and the corresponding add_stop method) support the creation of gradient patterns, which can be used as arguments to fill and stroke.

    • Scripts no longer need to declare their own functions as global in order to invoke them.

    • Simple Inkscape Scripting's print statement has been redefined to accept multiple arguments, just like Python's built-in print statement.

    • For advanced users, the root of the SVG XML tree is made available via an svg_root variable.

    • Layers can be created with the new layer function.

    • The add method on group- and layer-produced objects accepts a list of objects in addition to a single object.

    • All of inkex.paths is imported into the script's namespace. This provides convenient access to path-element constructors such as Move, Line, and Curve.

    • Transform from inkex.transforms is imported into the script's namespace. This provides a rich mechanism for manipulating object transformations. Transform objects can be used as a shape-creation function's transform parameter.

    Whew! More examples are included in the examples/ directory to demonstrate usage of these new features. There are also myriad improvements to the Simple Inkscape Scripting code itself, making it cleaner and more robust, but that are not visible to users.

    Source code(tar.gz)
    Source code(zip)
    simple_inkscape_scripting.zip(41.27 KB)
  • v1.2.1(Nov 23, 2021)

    This is a very minor release of Simple Inkscape Scripting. The only change is that the Help tab in the extension's dialog box has been replaced with a substantially shorter About tab, which mainly refers the reader to GitHub. This change is intended to address Inkscape's inability to reduce the size of a dialog box, as reported in issue #3.

    Source code(tar.gz)
    Source code(zip)
    simple_inkscape_scripting.zip(27.23 KB)
  • v1.2.0(Nov 4, 2021)

  • v1.1.0(Oct 22, 2021)

    Despite semantic versioning classifying this as a minor update, a large number of nice, new features have been added to Simple Inkscape Scripting since the initial release:

    • A new regular_polygon function produces regular polygons that are recognized as such by Inkscape's "stars and polygons" tool. Actually, because regular_polygon supports randomization, the shapes it produces do not have to be regular; and because it supports rounding, the shapes do not have to be polygons.
    • A new star function produces stars that are recognized as such by Inkscape's "stars and polygons" tool. It can even produce shapes that don't look much like stars given particular combinations of options.
    • A new group function lets programs group objects together. Objects can also be added to existing groups.
    • A new clone function produces a linked clone of an object. Changes to the original object in the GUI are applied automatically to all clones.
    • A new inkex_object function lets advanced users create an object using Inkscape's lower-level inkex API and make this available to Simple Inkscape Scripting.
    • print can be used as a debugging aid. Simple Inkscape Scripting now maps print to inkex.utils.debug, which produces its output in a dialog box once the script terminates.
    • The implementation is improved. Instead of an ID, all Simple Inkscape Scripting functions now return an object, which cleans up some of the extension's internal behavior.
    Source code(tar.gz)
    Source code(zip)
    simple_inkscape_scripting.zip(29.61 KB)
  • v1.0.0(Sep 26, 2021)

Owner
Scott Pakin
Scott Pakin
🗾 Streamlit Component for rendering kepler.gl maps

streamlit-keplergl 🗾 Streamlit Component for rendering kepler.gl maps in a streamlit app. 🎈 Live Demo 🎈 Installation pip install streamlit-keplergl

Christoph Rieke 39 Dec 14, 2022
Here I plotted data for the average test scores across schools and class sizes across school districts.

HW_02 Here I plotted data for the average test scores across schools and class sizes across school districts. Average Test Score by Race This graph re

7 Oct 27, 2021
IPython/Jupyter notebook module for Vega and Vega-Lite

IPython Vega IPython/Jupyter notebook module for Vega 5, and Vega-Lite 4. Notebooks with embedded visualizations can be viewed on GitHub and nbviewer.

Vega 335 Nov 29, 2022
An interactive UMAP visualization of the MNIST data set.

Code for an interactive UMAP visualization of the MNIST data set. Demo at https://grantcuster.github.io/umap-explorer/. You can read more about the de

grant 70 Dec 27, 2022
Fast scatter density plots for Matplotlib

About Plotting millions of points can be slow. Real slow... 😴 So why not use density maps? ⚡ The mpl-scatter-density mini-package provides functional

Thomas Robitaille 473 Dec 12, 2022
Bokeh Plotting Backend for Pandas and GeoPandas

Pandas-Bokeh provides a Bokeh plotting backend for Pandas, GeoPandas and Pyspark DataFrames, similar to the already existing Visualization feature of

Patrik Hlobil 822 Jan 07, 2023
Matplotlib JOTA style for making figures

Matplotlib JOTA style for making figures This repo has Matplotlib JOTA style to format plots and figures for publications and presentation.

JOTA JORNALISMO 2 May 05, 2022
UNMAINTAINED! Renders beautiful SVG maps in Python.

Kartograph is not maintained anymore As you probably already guessed from the commit history in this repo, Kartograph.py is not maintained, which mean

1k Dec 09, 2022
Area-weighted venn-diagrams for Python/matplotlib

Venn diagram plotting routines for Python/Matplotlib Routines for plotting area-weighted two- and three-circle venn diagrams. Installation The simples

Konstantin Tretyakov 400 Dec 31, 2022
Colormaps for astronomers

cmastro: colormaps for astronomers 🔭 This package contains custom colormaps that have been used in various astronomical applications, similar to cmoc

Adrian Price-Whelan 12 Oct 11, 2022
Getting started with Python, Dash and Plot.ly for the Data Dashboards team

data_dashboards Getting started with Python, Dash and Plot.ly for the Data Dashboards team Getting started MacOS users: # Install the pyenv version ma

Department for Levelling Up, Housing and Communities 1 Nov 08, 2021
Plotly Dash Command Line Tools - Easily create and deploy Plotly Dash projects from templates

🛠️ dash-tools - Create and Deploy Plotly Dash Apps from Command Line | | | | | Create a templated multi-page Plotly Dash app with CLI in less than 7

Andrew Hossack 50 Dec 30, 2022
Fractals plotted on MatPlotLib in Python.

About The Project Learning more about fractals through the process of visualization. Built With Matplotlib Numpy License This project is licensed unde

Akeel Ather Medina 2 Aug 30, 2022
An interactive GUI for WhiteboxTools in a Jupyter-based environment

whiteboxgui An interactive GUI for WhiteboxTools in a Jupyter-based environment GitHub repo: https://github.com/giswqs/whiteboxgui Documentation: http

Qiusheng Wu 105 Dec 15, 2022
Displaying plot of death rates from past years in Poland. Data source from these years is in readme

Average-Death-Rate Displaying plot of death rates from past years in Poland The goal collect the data from a CSV file count the ADR (Average Death Rat

Oliwier Szymański 0 Sep 12, 2021
BGraph is a tool designed to generate dependencies graphs from Android.bp soong files.

BGraph BGraph is a tool designed to generate dependencies graphs from Android.bp soong files. Overview BGraph (for Build-Graphs) is a project aimed at

Quarkslab 10 Dec 19, 2022
patchwork for matplotlib

patchworklib patchwork for matplotlib test code Preparation of example plots import seaborn as sns import numpy as np import pandas as pd #Bri

Mori Hideto 185 Jan 06, 2023
Interactive chemical viewer for 2D structures of small molecules

👀 mols2grid mols2grid is an interactive chemical viewer for 2D structures of small molecules, based on RDKit. ➡️ Try the demo notebook on Google Cola

Cédric Bouysset 154 Dec 26, 2022
Numerical methods for ordinary differential equations: Euler, Improved Euler, Runge-Kutta.

Numerical methods Numerical methods for ordinary differential equations are methods used to find numerical approximations to the solutions of ordinary

Aleksey Korshuk 5 Apr 29, 2022
Minimal Ethereum fee data viewer for the terminal, contained in a single python script.

Minimal Ethereum fee data viewer for the terminal, contained in a single python script. Connects to your node and displays some metrics in real-time.

48 Dec 05, 2022