Satin Studio Manual

What Is a Stitch Compiler?

A mathematical and engineering reference for turning artwork into machine embroidery

An embroidery machine is a very fast, very literal robot. It does not see a leaf, a letter, a patch, or a face. It sees a sequence of movements and state changes: move here with the needle down, move there with the needle up, cut the thread, change color, stop, and end.

A stitch compiler is the software system that translates between those two worlds.

It accepts a high-level description of what the embroidery should mean and look like, then produces a low-level program that a particular machine can execute. Along the way it must solve geometry problems, topology problems, routing problems, material problems, and aesthetic problems. It must also cope with an inconvenient fact: the “output device” is a stretchy, frictional, anisotropic piece of fabric rather than a sheet of obedient pixels.

Working definition

A stitch compiler synthesizes a robust, perceptually effective thread toolpath from a high-level design specification, subject to geometric, topological, mechanical, sequencing, and machine constraints.

This chapter develops that definition into a practical mathematical reference. The goal is not to claim that embroidery has one settled grand theory. It does not. Instead, this chapter assembles a useful theory from computational geometry, graph theory, operations research, differential geometry, material mechanics, computer graphics, perception, and compiler design.

The result is a model you can use to design an embroidery application, explain its behavior, build diagnostics, and decide where artistic judgment belongs.

Scope

The main subject is automated, two-dimensional machine embroidery on a hooped substrate. The mathematics also applies to free-standing lace, appliqué, embroidered electronics, tactile graphics, and shape-changing textiles, but those applications add their own constraints.

This chapter focuses on:

It does not attempt to document the binary layout of every commercial embroidery format, prescribe universal density values, or replace physical testing. Those details vary by machine, thread, needle, stabilizer, fabric, hooping, and production environment.

The entire subject in one picture

A stitch compiler is not a single “convert” button. It is a pipeline of representations, each of which answers a different class of questions.

flowchart LR
    A[Artwork and intent] --> B[Normalized Design IR]
    B --> C[Regions, topology, and layers]
    C --> D[Stitch primitive plan]
    D --> E[Continuous thread paths]
    E --> F[Discrete needle points]
    F --> G[Global routing and scheduling]
    G --> H[Machine Command IR]
    H --> I[Target format encoder]
    I --> J[Embroidery machine]
    J --> K[Physical stitch-out]
    K -. calibration feedback .-> B

The important design choice is the stack of intermediate representations, or IRs. An application that jumps directly from SVG paths to stitch coordinates throws away useful intent too early. Once “this is a satin border that should cover a shared edge” has become an anonymous list of points, many intelligent edits become difficult or impossible.

Where the mathematics lives

QuestionMain mathematical tools
What is inside the shape?planar geometry, winding numbers, Boolean operations
How many pieces and holes does it have?topology, connected components, Euler characteristic
Which way should the thread flow?line fields, vector calculus, differential geometry
How should a region be covered?sampling, scalar fields, offsets, computational fabrication
How can required lines be sewn continuously?graph theory, Euler tours, postman problems
In what order should objects be sewn?scheduling, TSP variants, precedence-constrained optimization
How will the fabric move?anisotropic elasticity, contact, friction, inverse mechanics
What will the viewer perceive?reflectance, color science, texture, perceptual loss functions
How does the design become machine commands?compiler passes, state machines, quantization, code generation

The categories overlap. A fill path may be geometrically valid but topologically disconnected, mechanically unstable, visually muddy, or expensive to sew. The job of the compiler is to negotiate all of those concerns without pretending they are the same concern.

Contents

Choose your route

You do not have to swallow the whole subject at once. Pick the route that matches the job in front of you:

The rest of this page explains the big ideas: what the compiler knows, how its pieces fit together, and where artistic choices enter.

The compiler model

1.1 Source language, target language, and execution

Let the high-level design be

\[D = (G, C, L, S),\]

where:

Let the physical setup be

\[B = (F, Z, T, N, H),\]

where \(F\) is fabric, \(Z\) is stabilizer, \(T\) is thread, \(N\) is needle and tension configuration, and \(H\) is hooping or fixture state.

Let the target machine be \(M\), including its work envelope, command set, coordinate resolution, speed behavior, needle configuration, and format capabilities.

The compiler emits a program

\[P = (c_0,c_1,\ldots,c_{n-1}),\]

where each command \(c_i\) may be a stitch movement, jump, trim, color change, needle selection, pause, or end marker.

The machine and material execute that program through a forward process

\[Y = \mathcal{E}(P; B, M, \xi),\]

where \(Y\) is the physical result and \(\xi\) represents uncertainty: tension drift, fabric variation, thread behavior, hooping error, speed variation, and other unmodeled effects.

Digitizing is the inverse problem:

\[(D,B,M) \longrightarrow P\]

such that

\[\mathcal{E}(P;B,M,\xi) \approx \text{the intended result described by } D.\]

This inverse is not unique. Two programs can produce nearly the same silhouette while differing in sheen, texture, stiffness, sewing time, thread consumption, and robustness. That non-uniqueness is where style enters.

1.2 The optimization view

A convenient abstract formulation is

\[P^* = \arg\min_{P\in\mathcal{F}} \left[ \lambda_a E_{\text{appearance}} + \lambda_g E_{\text{geometry}} + \lambda_m E_{\text{mechanics}} + \lambda_r E_{\text{risk}} + \lambda_t E_{\text{time}} + \lambda_w E_{\text{waste}} \right],\]

where \(\mathcal{F}\) is the set of machine-feasible programs.

Typical terms include:

The weights \(\lambda_i\) are not merely tuning constants. They encode product policy. A production logo system may put repeatability ahead of artistic texture. A thread-painting tool may accept a slow stitch-out in exchange for directional expression. A tactile graphic generator may optimize distinguishability rather than visual fidelity.1

Do not make every preference a hard constraint.

Hard constraints are appropriate for things such as hoop bounds or unsupported commands. “Avoid a visible travel stitch” is usually a soft objective because there may be no completely invisible route. Turning every preference into a prohibition can make the feasible set empty.

1.3 A bilevel physical formulation

The physical result depends on how the material settles after the thread is placed. A more honest formulation is therefore bilevel:

\[\begin{aligned} P^* &= \arg\min_P L\bigl(D, R(P,u^*)\bigr), \\ u^* &= \arg\min_u E_{\text{fabric+thread}}(u;P,B). \end{aligned}\]

The inner problem finds the deformed equilibrium \(u^*\) of fabric and thread. The outer problem changes the stitch program so that the deformed, rendered result \(R(P,u^*)\) matches the design.

A full yarn-level solve is expensive. Research systems can model woven and knitted cloth at the yarn level, but production applications usually rely on simpler shell models, measured compensation tables, or learned surrogate models.23

1.4 Hard constraints, soft constraints, and artistic choices

It helps to classify requirements before choosing an algorithm.

Hard constraints

A violation makes the output invalid or unsafe to encode:

Soft constraints

A violation may sew, but with reduced quality:

Artistic choices

Several feasible answers may be equally defensible:

A good application keeps these categories visible. It should report a hard error, warn about a soft violation, and expose an artistic trade-off rather than treating all three as the same red exclamation mark.

A reference compiler architecture

The architecture below is one practical way to turn the mathematics into software.

13.1 Intermediate representations

Artwork IR

Preserves imported intent:

ArtworkObject
  id
  sourceGeometry
  transform
  paint
  clipPath
  semanticTags
  userGuides
  sourceProvenance

Region IR

Represents cleaned planar regions and relationships:

Region
  id
  boundary
  holes
  visibleShape
  sewShape
  overlapMargins
  adjacency
  layerConstraints
  materialZone

Primitive IR

Describes how a region should become thread:

StitchPrimitive
  kind
  regionId
  color
  directionField
  spacingField
  stitchLengthPolicy
  underlayPlan
  compensationPolicy
  entryExitCandidates
  artisticParameters

Continuous Path IR

Stores curves before needle sampling:

ThreadPath
  curves
  requiredSegments
  optionalTravel
  continuityGroups
  corners
  preferredDirection
  layerId
  provenance

Stitch Plan IR

Stores discrete movements with semantic annotations:

StitchNode
  positionMm
  operationIntent
  primitiveId
  layerId
  cornerClass
  lockRole
  diagnostics

Machine Command IR

Contains target-neutral executable operations:

MachineCommand
  opcode
  positionMm?
  color?
  needle?
  sourceStitchIds

Encoded output

Contains backend-specific bytes and an export report.

13.2 Passes and invariants

Each pass should declare what it requires and guarantees.

PassRequiresGuarantees
Normalizeparseable sourceexplicit units, transforms, finite geometry
Arrangenormalized geometryvalid regions, components, holes, adjacency
Plan primitivesregion semanticstyped stitch objects and layer constraints
Build fieldsguides and region meshsampled direction, spacing, confidence fields
Generate pathsprimitive validitycontinuous paths inside permitted domains
Sample stitchescontinuous pathsdiscrete points meeting local constraints
Routeobjects and DAGvalid global order and transitions
Compensate/refinematerial profileadjusted geometry with recorded deltas
Lowermachine profilesupported command stream
Encodebackend schemavalid file and export diagnostics

An invariant should be machine-checkable whenever possible. “Looks reasonable” is not an invariant.

13.3 The main compile function

compile(design, materialProfile, machineProfile, options):
    artwork = normalize(design)
    report(artwork.diagnostics)

    arrangement = buildPlanarArrangement(artwork)
    regions = deriveSewRegions(arrangement, options.overlapPolicy)

    primitives = chooseAndConfigurePrimitives(regions, options.style)
    layerGraph = buildLayerDAG(primitives)
    assertAcyclic(layerGraph)

    fields = solveDirectionDensityAndCompensationFields(
        primitives,
        materialProfile,
        options
    )

    continuousPaths = generateContinuousPaths(primitives, fields)
    localPlans = sampleNeedlePoints(continuousPaths, machineProfile)

    schedule = routeAndSchedule(
        localPlans,
        layerGraph,
        machineProfile,
        materialProfile
    )

    refinedPlan = compensateAndValidate(
        schedule,
        materialProfile,
        machineProfile
    )

    machineIR = lowerToMachineCommands(refinedPlan, machineProfile)
    output = encode(machineIR, machineProfile.format)

    return {
        output,
        preview: renderDecodedOutput(output),
        metrics: computeMetrics(refinedPlan, machineIR),
        diagnostics: collectDiagnostics(),
        provenance: buildProvenanceMap()
    }

13.4 Provenance

Every generated stitch should be traceable back to:

Provenance enables useful messages:

“These 14 short stitches were introduced by the satin-corner pass for object petal-7, then collapsed during 0.1 mm target quantization.”

That is much more actionable than “Design contains short stitches.”

13.5 Determinism

Randomized fills and heuristic routing are useful, but the compiler should be deterministic for a given seed, version, and profile. Record:

Reproducibility is essential for debugging and production approval.

13.6 Incremental compilation

A small edit should not force every stage to rerun. Useful dependency boundaries include:

Treat the pipeline as a dependency graph, not a fixed monolithic function.

Engineering principles that fall out of the math

The preceding chapters can be reduced to a set of practical rules. These are not substitutes for the theory; they are the design consequences of it.

18.1 Preserve intent longer than geometry

Keep “satin border,” “rear petal,” “covered travel zone,” and “direction guide” alive until the passes that need them have run. A flat point list is a poor source language.

18.2 Resolve topology before polishing coordinates

Connected components, holes, branches, and layer order determine which algorithms are possible. No amount of point smoothing repairs an incorrect component graph.

18.3 Treat direction and density as fields

A single fill angle and one density number are special cases. Spatial fields provide the right abstraction even when the initial UI exposes only constants.

18.4 Keep row spacing separate from stitch length

Row spacing controls cross-row coverage. Stitch length controls sampling along a row. Coupling them makes the compiler harder to reason about and produces unnecessary density changes.

18.5 Entry and exit are part of a primitive

A stitch object is not complete until it exposes feasible entry and exit states, attachment requirements, and traversal alternatives. Routing cannot be bolted on after the object has been frozen into an arbitrary path.

18.6 Underlay is a structural layer

Generate, schedule, validate, and preview it as first-class geometry. “Underlay enabled” is not enough to explain what will be sewn.

18.7 Local perfection can produce global nonsense

The shortest route through each object may create many trims between objects. The smoothest direction field may create an impossible path topology. Optimize in layers and revisit local decisions when global costs change.

18.8 Fabric is an input, not an afterthought

The same stitch program is not the same fabrication process on denim, piqué, jersey, felt, and free-standing lace. Material, stabilizer, thread, needle, tension, speed, and hooping belong in the compile context.

18.9 Hidden travel is a temporal claim

A travel stitch is hidden only if a later layer covers it after deformation. Visibility depends on schedule, overlap, and material behavior—not merely on whether the line lies inside some original vector shape.

18.10 Compensation should be spatial and directional

A global “expand by 0.3 mm” control is useful as a fallback. The underlying model should support different corrections by boundary location, stitch direction, region width, and material confidence.

18.11 Lower late and report loss

Keep a rich machine-neutral command IR, then lower to the selected format. When the target cannot express a semantic operation, emulate it explicitly or warn. Never silently redefine the design.

18.12 Decode the final bytes

The only honest export preview is based on decoded target output. Backend quantization and command rewriting are part of compilation.

18.13 Make randomness reproducible

Randomized staggering and texture are valuable. Record the seed, algorithm version, and profile versions so that “random” does not mean “unreviewable.”

18.14 Prefer measurements to folklore—but retain expert overrides

Calibration data can improve defaults and reveal uncertainty. It cannot cover every unusual material, thread, machine, or artistic effect. Let experts override the model, and record the override as provenance.

18.15 Physical testing closes the loop

Simulation and diagnostics reduce failed runs; they do not abolish the need for stitch-outs. A production compiler is a cyber-physical system, and its regression suite should include the physical world.

The open research frontier

There is no single, universally accepted grand theory of embroidery computation. A practical stitch compiler is a synthesis of several mature fields plus a number of unsolved integration problems.

19.1 A fast, differentiable embroidery simulator

The ideal forward model would predict:

It would also expose derivatives of the result with respect to stitch positions, direction, density, underlay, and sequence. That would permit gradient-based inverse design rather than hand-authored compensation rules.

The difficulty is scale. A design may contain tens of thousands of stitches, while fabric and thread interactions occur at much finer scales. Useful research will probably combine reduced mechanics, differentiable approximations, and data-driven residual models rather than simulate every fiber.

19.2 Joint field, topology, and path optimization

Most stitch compilers solve direction, spacing, path connectivity, and routing in separate stages. Yet these decisions interact:

A unified formulation would optimize field topology, scalar parametrization, curve extraction, and connectivity together. The challenge is that topology changes are discrete while field values and paths are continuous.

19.3 Joint appearance and mechanics

A stitch angle changes both sheen and stiffness. Density changes both coverage and deformation. Underlay changes both loft and mechanical support. Optimizing those channels independently leaves quality on the table.

A richer compiler would seek a Pareto set over appearance, mechanics, and production cost, then expose understandable choices to the user.

19.4 Probabilistic failure prediction

Thread breaks, skipped stitches, needle deflection, registration drift, and puckering are not deterministic thresholds. They depend on history and uncertain process variables.

A useful model would estimate

\[\Pr(\text{failure type }k\mid P,B,M,\text{history})\]

and explain which local features contribute most. The hard part is collecting enough labeled production data while respecting differences between machines and shops.

19.5 Semantic artwork understanding

A human recognizes that a dark curve is a vein, a border should cover an edge, two shapes form one letter, and a tiny highlight can be omitted. Generic vector import does not.

Satin Studio infers candidate semantics from vector structure, raster appearance, design history, and examples. It keeps uncertainty visible, distinguishing “this is definitely a closed region” from “this probably represents an eye highlight.”

19.6 Explainable auto-digitizing

Automatic digitizing should produce a decision trace:

Explainability is not merely educational. It makes the system correctable and turns failures into better constraints rather than mysterious retries.

19.7 Standard benchmark designs

The field lacks a widely adopted benchmark suite that combines:

Such a suite would make algorithms comparable and help separate impressive previews from reliable fabrication.

19.8 Portable material profiles

A compensation profile learned on one machine may partly transfer to another, while some effects belong mainly to fabric and others to tension or motion control. Factorizing those influences is a promising system-identification problem.

A portable profile format would also need uncertainty, validity ranges, measurement provenance, and a way to compose fabric, stabilizer, thread, needle, and machine contributions.

19.9 Embroidery as programmable matter

Free-standing lace, anisotropic stitching, shape-changing textiles, and embroidered metamaterials turn the compiler into a structural-design system. The target may be a force–displacement curve, a fold, an auxetic response, or a tactile interaction rather than a flat picture.4567

This is not a side note. It reveals the general form of the field:

Embroidery is the programming of geometry, appearance, and mechanics through constrained thread placement.

So, what is a stitch compiler?

A stitch compiler does more than convert files, generate fills, or find short paths. It is a domain-specific inverse-fabrication compiler.

Its source program describes geometry, appearance, layering, and artistic intent. Its target program describes movements and machine state. Between them lies a stack of intermediate representations and solvers that manage topology, fields, coverage, routing, deformation, perception, and target limitations.

The most compact mathematical description is:

\[P^* = \arg\min_{P\in\mathcal{F}(M)} \mathbb{E}_{\xi} \left[ L\!\left(D,\mathcal{E}(P;B,M,\xi)\right) \right],\]

where:

That equation is too broad to solve in one shot, which is why the compiler is a pipeline. Geometry turns artwork into valid regions. Topology explains components, holes, branches, and unavoidable singularities. Field theory describes direction and density. Sampling turns continuous paths into penetrations. Graph theory and operations research organize the sequence. Mechanics predicts how the substrate will answer back. Rendering and perception define what success looks like. Machine lowering makes the plan executable.

And art? Art chooses the specification, the decomposition, the constraints, and the trade-offs. The compiler does not remove artistic judgment. It gives that judgment a rigorous place to operate.

Final definition

A stitch compiler translates design intent into a reproducible machine program by solving a hybrid discrete–continuous optimization problem over geometry, topology, thread paths, material response, visual perception, and machine semantics.

References

References and further reading

The following sources are a practical starting point rather than an exhaustive bibliography. The embroidery-specific literature is relatively small, so adjacent work in computational fabrication, direction-field design, cloth mechanics, and graph routing is essential.

For the central embroidery-path problem, begin with Liu et al. on direction-aware streamlines and Tian et al. on spiral paths. For the mathematical machinery behind fields, continue with direction-field and vector-field processing references. For the material side, the cloth-modeling and computational-embroidery papers show why geometry alone is not enough. For real implementation semantics, inspect the official Ink/Stitch documentation and pyembroidery source.

1

Margaret Ellen Seehorn, Gene S.-H. Kim, Aashaka Desai, Megan Hofmann, and Jennifer Mankoff, “Enhancing Access to High Quality Tangible Information through Machine Embroidered Tactile Graphics,” Proceedings of the ACM Symposium on Computational Fabrication (SCF ’22), Article 23, 2022. https://doi.org/10.1145/3559400.3565586

2

Gabriel Cirio, Jorge López-Moreno, David Miraut, and Miguel A. Otaduy, “Yarn-Level Simulation of Woven Cloth,” ACM Transactions on Graphics 33, no. 6, Article 207, 2014. https://doi.org/10.1145/2661229.2661279

3

Georg Sperl, Rosa M. Sánchez-Banderas, Manwen Li, Chris Wojtan, and Miguel A. Otaduy, “Estimation of Yarn-Level Simulation Models for Production Fabrics,” ACM Transactions on Graphics 41, no. 4, Article 65, 2022. https://doi.org/10.1145/3528223.3530167

8

Qiming Tian, Yupin Luo, and Dongcheng Hu, “Spiral-Fashion Embroidery Path Generation in Embroidery CAD Systems,” Computer-Aided Design 38, no. 2, pp. 125–133, 2006. https://doi.org/10.1016/j.cad.2005.08.004

9

Zhenyuan Liu, Michal Piovarči, Christian Hafner, Raphaël Charrondière, and Bernd Bickel, “Directionality-Aware Design of Embroidery Patterns,” Computer Graphics Forum 42, no. 2, pp. 397–409, 2023. https://doi.org/10.1111/cgf.14770

10

Xiangjia Chen, Guoxin Fang, Wei-Hsin Liao, and Charlie C. L. Wang, “Field-Based Toolpath Generation for 3D Printing Continuous Fibre Reinforced Thermoplastic Composites,” Additive Manufacturing 49, Article 102470, 2022. https://doi.org/10.1016/j.addma.2021.102470

6

Kate S. Glazko, Alexandra A. Portnova-Fahreeva, Arun Mankoff-Dey, Afroditi Psarra, and Jennifer Mankoff, “Shaping Lace: Machine Embroidered Metamaterials,” Proceedings of the 9th ACM Symposium on Computational Fabrication (SCF ’24), 2024. https://doi.org/10.1145/3639473.3665792

11

Ink/Stitch, “Tatami Stitch (Fill Stitch),” official documentation. https://inkstitch.org/docs/stitches/fill-stitch/

12

Fernando de Goes, Mathieu Desbrun, and Yiying Tong, “Vector Field Processing on Triangle Meshes,” ACM SIGGRAPH 2016 Course Notes, 2016; and Felix Knöppel, Keenan Crane, Ulrich Pinkall, and Peter Schröder, “Globally Optimal Direction Fields,” ACM Transactions on Graphics 32, no. 4, Article 59, 2013. Course notes; direction-field paper

13

Jack Edmonds and Ellis L. Johnson, “Matching, Euler Tours and the Chinese Postman,” Mathematical Programming 5, pp. 88–124, 1973. https://doi.org/10.1007/BF01580113

14

Ink/Stitch, “Tools: Stroke—Redwork,” official documentation. The tool’s routing goal is to traverse every path exactly twice. https://inkstitch.org/docs/stroke-tools/

15

Ink/Stitch, “Commands,” official documentation. https://inkstitch.org/docs/commands/

16

Huamin Wang, James F. O’Brien, and Ravi Ramamoorthi, “Data-Driven Elastic Models for Cloth: Modeling and Measurement,” ACM Transactions on Graphics 30, no. 4, Article 71, 2011. https://doi.org/10.1145/2010324.1964966

17

Ink/Stitch, “Satin Column,” official documentation. https://inkstitch.org/docs/stitches/satin-column/

4

Abhinit Sati, Ioannis Karamouzas, and Victor B. Zordan, “DIGISEW: Anisotropic Stitching for Variable Stretch in Textiles,” Proceedings of the ACM Symposium on Computational Fabrication (SCF ’21), Article 3, 2021. https://doi.org/10.1145/3485114.3485121

5

Yu Jiang, Narjes Pourjafarian, Alice Haynes, and Jürgen Steimle, “Embrogami: Shape-Changing Textiles with Machine Embroidery,” Proceedings of the 37th Annual ACM Symposium on User Interface Software and Technology (UIST ’24), 2024. https://doi.org/10.1145/3654777.3676431

7

Ayesha Nabila, Hua Ma, and Junichi Yamaoka, “4D Embroidery: Implementing Parametric Structures in Textiles for Sculptural Embroidery,” UbiComp/ISWC ’22 Adjunct, pp. 88–90, 2022. https://doi.org/10.1145/3544793.3560358

18

Xinling Chen, Michael McCool, Asanobu Kitamoto, and Stephen Mann, “Embroidery Modeling and Rendering,” Proceedings of Graphics Interface 2012, pp. 131–139, 2012. https://doi.org/10.5555/2305276.2305299

19

EmbroidePy, “pyembroidery,” an open-source Python library for reading and writing embroidery formats. https://github.com/EmbroidePy/pyembroidery

20

Ink/Stitch, “Tack and Lock Stitches,” official documentation. https://inkstitch.org/docs/stitches/lock-stitches/