Sign in

    sayoi7799/moon_rough/path_data does not have a README file

    PathError

    pub(all) suberror PathError {
    InvalidCharacter(Int)
    ParamNotANumber(Char, String)
    EndedShort
    NumberAfterClose
    } derive(Eq,
    Debug
    )

    Why a path string could not be parsed. rough.js throws (or, for AfterClose, loops forever) on these inputs; moon_rough reports them.

    Segment

    pub(all) struct Segment {
    key : Char
    data : Array[Double]
    } derive(Eq,
    Debug
    )

    One SVG path command: its letter (M, l, A, z, ...) and numeric parameters, as path-data-parser represents it.

    absolutize

    fn absolutize(segments : Array[Segment]) -> Array[Segment]

    absolutize(segments): rewrites relative commands as absolute ones (m -> M, c -> C, ..., z -> Z).

    normalize

    fn normalize(segments : Array[Segment]) -> Array[Segment]

    normalize(segments): turns absolute segments (see absolutize) into M, L, C and Z only. H/V become lines; S, Q, T and arcs become cubic Béziers.

    parse_path

    fn parse_path(d : StringView) -> Array[Segment] raise PathError

    parsePath(d): splits path data into segments, keeping relative commands and implicit repetitions as written (M 1 2 3 4 is M 1 2, L 3 4). Data not starting with a move-to is parsed as "M0,0" + d.

    serialize

    fn serialize(segments : Array[Segment]) -> String

    serialize(segments): the inverse of parse_path, formatted like path-data-parser (C x1 y1, x2 y2, x y, numbers as in JavaScript).