Skip to content

Repository files navigation

Diastasis - SVG Layer Separation Tool

Diastasis separates complex SVG artwork into production-ready layers.

Features

  • Three separation modes:
    • Overlaid Complexity: overlap-aware layering.
    • Flat Complexity: strict area-exclusive separation.
    • Color Separation: one plate per ink color (screen-print / vinyl / risograph), with tolerance-based merging to minimize plate count.
  • minimum_layers algorithm (default): portfolio of coloring strategies, iterated refinement, and exact search on small graphs — the summary states when the layer count is provably the minimum possible.
  • Headless CLI (python cli.py) with batch folder processing.
  • Per-layer file export: one registered SVG per layer (shared canvas and crop marks) for production stacking.
  • High-fidelity export: untransformed rects/circles/ellipses/polygons keep their original markup; original path data preserved whenever valid.
  • Broad SVG input coverage: transforms (incl. groups), viewBox coordinate spaces, compound paths with holes (nonzero/evenodd), polyline, defs/use references, curved segments sampled accurately.
  • Quality presets:
    • Accurate, Balanced, Fast.
  • Complexity estimator:
    • shape count, candidate pairs, graph density, ETA.
  • Batch mode:
    • process all .svg files in a folder with current settings.
  • Export profiles:
    • Illustrator-safe, Print, Web.
  • Visible-boundary clipping (Clip Shapes To Visible Boundaries).
  • Performance mode for weaker systems / huge files.
  • Flat controls:
    • touch policy (No edge/corner touching, Allow corner touching)
    • overlap priority (Source order, Largest first, Smallest first)
  • Layer analytics in summary:
    • overlap/conflict count
    • tiny fragment count
    • per-layer area share

Installation

git clone https://github.com/tsevis/Diastasis.git
cd Diastasis
pip install -e ".[gui]"     # library + CLI + GUI dependencies

This installs the diastasis command. For headless use (servers, CI), pip install -e . is enough — the GUI extras are only needed for gui.py.

Run

python gui.py

or:

./run_gui.sh

Typical Workflow

  1. Click Select SVG.
  2. Choose Quality Preset and Export Profile.
  3. Click Estimate Complexity (recommended for heavy files).
  4. Choose mode (Overlaid Complexity or Flat Complexity).
  5. Set optional controls:
    • Clip Shapes To Visible Boundaries
    • Performance Mode
  6. Click Process.
  7. Export with:
    • Save Layers As...
    • Save Clipped 1-Layer As...

Command Line

# One file -> output/artwork_layered.svg (+ summary with optimality proof)
diastasis artwork.svg -o output/

# Strict flat separation, one registered SVG file per layer
diastasis artwork.svg -o output/ --mode flat --separate-files

# Whole folder with print settings
diastasis --batch input_folder/ -o output/ --profile Print

# Color separation: one plate per ink, merge near colors, unify to a single ink
diastasis artwork.svg -o output/ --mode color --color-tolerance 12 --unify-plate-colors

# Clean cut/print plates: one path per ink with seams between tiles removed
diastasis artwork.svg -o output/ --mode color --merge-fragments

# Non-overlapping clipped mosaic as one flat SVG layer
diastasis artwork.svg -o output/ --clip --single-clipped-layer

# Check how heavy a file is before processing
diastasis artwork.svg --estimate

python cli.py ... works too when running from a source checkout. Run diastasis --help for all options (algorithm, touch policy, overlap priority, clipping, stroke-aware footprints, performance mode, recoloring).

Batch Workflow

  1. Configure settings as desired (mode, preset, profile, clipping, etc.).
  2. Click Batch Process Folder.
  3. Choose input folder (SVG files).
  4. Choose output folder.

Each file is processed with the same active settings.

Export Profiles

  • Illustrator-safe: balanced precision, crop marks included.
  • Print: higher path precision, crop marks included.
  • Web: lower precision, no crop marks.

Programmatic Usage

from diastasis import run_diastasis, save_layers_to_files

shapes, coloring, summary, w, h = run_diastasis(
    "input.svg",
    mode="flat",
    flat_algorithm="minimum_layers",
    flat_touch_policy="any_touch",
    flat_priority_order="source",
    clip_visible_boundaries=True,
    performance_mode=False,
)

save_layers_to_files(
    shapes,
    coloring,
    "output",
    "job",
    w,
    h,
    preserve_original_colors=True,
    export_profile="Illustrator-safe",
)

License

MIT

About

Diastasis is a designer-focused SVG separation tool that converts complex vector artwork into production-ready layers using Overlaid and Flat complexity modes, with clipping, batching, performance presets, and export profiles for Illustrator, print, and web workflows.

Topics

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages