SVGToolBox

Study

Working question: what preparation does an SVG need before it becomes a plot?

The thing is an older plotter preparation tool for palette quantization, hatching, path optimization, and layer separation. Its active successor is Gantry.

The current page keeps the project as context. The study note should capture what this tool taught and which ideas were later absorbed into Gantry.

Deprecated: SVGToolBox remains online as a historical project note. Its functionality has been absorbed into Gantry, the current all-Java plotter toolkit that combines SVG preparation, positioning, command generation and G-code output.

A modular Java CLI and GUI tool that prepares SVG files for pen plotters. It takes vector art designed for screens (with solid fills and arbitrary colors) and transforms it for the physical world: quantized colors matching your pen collection, fills converted to hatch patterns, optimized path order to minimize pen travel, and output organized into Inkscape-compatible layers.

Source: github.com/utrost/SVGToolBox · License: AGPL-3.0 · Successor: Gantry

The Problem

Generative art tools, design software, and vector editors produce SVGs optimized for displays. A pen plotter has different constraints: it draws with physical pens from a fixed set of colors, it cannot fill areas, and every unnecessary pen lift costs time. An SVG that looks perfect on screen needs significant processing before it plots well.

The Pipeline

SVGToolBox processes SVGs through a chain of ten stages. Each stage modifies the SVG DOM in-place:

  • Visibility — hide or show layers based on export settings
  • StyleNormalizer — convert CSS classes to inline attributes for reliable downstream processing
  • Rotate — rotate canvas 90°, 180°, or 270°
  • StrokeWidth — normalize line weights to match physical pen tip size, globally or per layer
  • Palette — quantize colors to available pens using perceptual color matching
  • Simplify — reduce path complexity via the Ramer-Douglas-Peucker algorithm
  • Hatch — convert solid fills to line patterns using scanline geometry
  • Layer — flatten groups into Inkscape layers, one per pen color
  • Crop — crop output to A4, Letter, or custom dimensions
  • PathOptimize — reorder paths to minimize pen travel

The stages are independent. Use all of them or just the ones you need.

Hatching

The core feature. A plotter cannot fill a shape with solid color, but it can approximate fills by drawing parallel lines inside the shape boundary. SVGToolBox offers five hatch patterns:

  • Linear: parallel lines at a configurable angle
  • Crosshatch: two sets of intersecting lines
  • ZigZag: connected zigzag strokes with fewer pen lifts
  • Wave: sinusoidal lines for organic textures
  • Dot: stipple patterns

Each color can have its own hatch settings — angle, gap and pattern type — allowing visual differentiation between filled regions even with a single pen.

Per-color style configuration used pattern names for readability:

svgtoolbox -i input.svg -o output.svg \
  -p "#00FFFF,#FF00FF,#000000" \
  -h -w 0.5 \
  --style "#00FFFF:45:6.0:linear;#FF00FF:135:4.0:linear;#000000:0:8.0:cross"

GUI

A Swing interface with FlatLaf Material Design theming provides live preview of the processing pipeline. Each layer has its own independent controls for hatch pattern, angle, gap, stroke width, and export visibility. An integrated SVG analyzer detects layer structure automatically. Processing runs asynchronously to keep the UI responsive during heavy geometry operations.

Before / After

Input → Processed

Raw generative-art SVG becomes palette-reduced, stroke-normalized, hatched and path-optimized output, ready for the plotter.

Tech Stack

Java 17, Apache Batik for SVG parsing, Maven build with Uber-JAR output. No runtime dependencies beyond a JVM.

Successor

SVGToolBox is no longer the active endpoint of the toolchain. Its processors have moved into Gantry, specifically the svgtoolbox-core module and the optional “Process SVG” import tab.

See also: Gantry, PPCT, From Pixel to Pen, Generative Art, SVG2WaterColor, CityPlot, VHS, Primitive, Vectorize