needlerail

    Standalone geometry-to-embroidery compiler: running, satin and even-odd fill stitches, DST and SVG proofs

    embroidery
    dst
    geometry
    stitch-planning
    Download zip
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    5 days ago
    Downloads
    15

    No dependencies

    #zhangbowen2006/needlerail

    Command

    pub struct Command {
    position : Point
    kind : Kind
    thread : Int
    }

    Kind

    pub(all) enum Kind {
    Stitch
    Jump
    Color
    End
    } derive(Eq)

    Kind::equal

    #deprecated("`Kind::equal` is deprecated, use `Eq::equal` instead.")
    fn Kind::equal(Kind, Kind) -> Bool

    Kind::not_equal

    #deprecated("`Kind::not_equal` is deprecated, use `Eq::not_equal` instead.")
    fn Kind::not_equal(x : Kind, y : Kind) -> Bool

    Object

    pub(all) struct Object {
    shape : Shape
    thread : Int
    }

    Plan

    pub struct Plan {
    // private fields
    }

    Plan::commands

    fn Plan::commands(self : Plan) -> Array[Command]

    Plan::dst

    fn Plan::dst(self : Plan) -> Bytes

    512-byte ASCII header plus three-byte records, including one end record. The file carries color-change commands, not thread RGB values or trim codes.

    Plan::report

    fn Plan::report(self : Plan) -> Json

    Stable machine-independent JSON command list; positions remain in 0.1 mm.

    Plan::settings

    fn Plan::settings(self : Plan) -> (Int, Int, Int)

    Plan::svg

    fn Plan::svg(self : Plan) -> String

    Proof of needle/travel geometry only; it does not simulate fabric or thread.

    Point

    pub(all) struct Point {
    x : Int
    y : Int
    } derive(Eq, ToJson)

    Integer units: 10 units = 1 mm. Screen coordinates: x right, y down.

    Point::equal

    #deprecated("`Point::equal` is deprecated, use `Eq::equal` instead.")
    fn Point::equal(Point, Point) -> Bool

    Point::not_equal

    #deprecated("`Point::not_equal` is deprecated, use `Eq::not_equal` instead.")
    fn Point::not_equal(x : Point, y : Point) -> Bool

    Point::to_json

    #deprecated("`Point::to_json` is deprecated, use `ToJson::to_json` instead.")
    fn Point::to_json(Point) -> Json

    Shape

    pub(all) enum Shape {
    Running(Array[Point])
    Satin(Array[Point], Array[Point], Int)
    Fill(Array[Array[Point]], Int)
    }

    compile

    fn compile(objects : Array[Object], width : Int, height : Int, max_step : Int) -> Result[Plan, String]

    Compiles independent objects in caller order; no automatic thread sorting.

    compile_json

    fn compile_json(text : String) -> String

    Pure compilation: host writes the returned bytes, SVG and report.

    fill

    fn fill(rings : Array[Array[Point]], spacing : Int, max_step : Int) -> Result[Array[Array[Point]], String]

    Simple, non-touching rings, interpreted with the even-odd fill rule. Returns separate sewing spans: callers must jump between these spans.

    kind_name

    fn kind_name(k : Kind) -> String

    parse_job

    fn parse_job(text : String) -> Result[Plan, String]

    running

    fn running(path : Array[Point], max_step : Int) -> Result[Array[Point], String]

    Subdivision retains each vertex, removes consecutive duplicate positions, and leaves headroom for integer rounding so Euclidean length stays bounded.

    satin

    fn satin(left : Array[Point], right : Array[Point], spacing : Int, max_step : Int) -> Result[Array[Point], String]

    Rails must have matching direction. Samples each by normalized arc length. Oversize cross-rail stitches fail instead of silently changing stitch type.