This directory provides a number of examples demonstrating the breadth of Simple Inkscape Scripting's capabilities.
The examples in this directory generally assume a "user unit" is about the size of a pixel (roughly 1/100" or 1/4 mm) and that the page size is at least 600×600 user units. See Units for a detailed explanation of how units and viewboxes work in SVG and Inkscape.
If some of the output from the examples appears with abnormally thick lines or crowded shapes or comes out much larger than the page size, use Inkscape's Document Properties dialog box to alter the page size and scale/viewbox, e.g. to a page of 1024×768px and a viewbox of 1024×768. The following Simple Inkscape Scripting code automates that task:
canvas.true_width = 1024
canvas.true_height = 768
canvas.viewbox = [0, 0, 1024, 768]
Example | Description |
---|---|
Animation | Demonstrate how to create an SVG SMIL animation. |
Binary tree | Draw a binary tree. The canvas should be about as wide as A4 or U.S. Letter paper to avoid node overlap in the deepest level of the tree. |
Boolean ops | Apply Boolean path operations to various objects. |
Brick pyramid | Draw a brick pyramid. |
Chalkboard | Draw a chalkboard with a repeated message written on it. |
Clipping path | Demonstrate how to apply a clipping path to a number of objects. |
Clone wave | Draw a wave of cloned objects. |
Drop shadow | Draw a circle with a drop shadow. |
Ellipses | Draw concentric ellipses. |
Gradient template | Show how to reuse a gradient pattern. |
Guides | Place guides in the document |
Holes | Draw a few shapes with holes in them. |
Html | Embed HTML code within an SVG image. |
Hyperlinks | Create a set of graphical hyperlinks. |
Image spiral | Draw a spiral out of Inkscape logos downloaded from the Web. |
Inkex paths | Show how to draw a path using the functions provided by the inkex.paths module (https://tinyurl.com/2p9dna4f) as an alternative to path commands expressed as alternating strings and floats. |
Linear gradient | Fill a shape with a gradient pattern. |
Markers | Draw arrows with begin, middle, and ending markers. |
Mask | Demonstrate how to apply a mask to a number of objects. |
Metadata | Add metadata to an image. |
Move rectangles | Move all rectangles in the image 2cm to the right. All other shapes are left alone. |
New layer | Add a layer to an image. |
Overlapping circles | Draw an array of hundreds of overlapping circles. |
Path effects | Demonstrate the application of live path effects to a curve. |
Pixels to rectangles | Show how to use the Python Imaging Library to convert each pixel of a bitmapped image to a colored rectangle. |
Poly by angle | Draw (possibly self-intersecting) polygons. |
Screen vs print | Create a printable page that is differently sized and disjoint from the main canvas. |
Sierpinski triangle | Draw a colorful Sierpinski triangle. |
Speedometer | Draw an unnumbered speedometer. |
Star groups | Draw rows of stars with the stars in each row grouped together. |
Stroke to path | Invoke Inkscape's Path → Stroke to Path function. |
Text flow | Flow text into a frame. |
Text path | Place text on a curved path. |
Turtle spiral | Create a path using turtle graphics and render it. |
Units | Demonstrate the use of explicitly specified units . |
-
Animation produces an animated SVG image, but Inkscape has no mechanism for rendering animations. Save the resulting SVG file and open it in a Web browser to watch the animation.
-
Poly by angle only defines a function; it does not by itself draw anything on the page. Read the header comments for usage instructions.