Sign in

    sayoi7799/moon_rough/core does not have a README file

    Drawable

    pub struct Drawable {
    shape : Shape
    options : ResolvedOptions
    sets : Array[OpSet]
    }

    A generated shape: backend-independent op sets plus the options needed to paint them.

    FillStyle

    pub(all) enum FillStyle {
    Hachure
    Solid
    Zigzag
    CrossHatch
    Dots
    Dashed
    ZigzagLine
    } derive(Eq,
    Debug
    )

    fillStyle. rough.js treats unknown names as hachure.

    FillStyle::from_name

    fn FillStyle::from_name(name : StringView) -> FillStyle

    Parses a rough.js fill style name; like rough.js, anything unknown is Hachure.

    FillStyle::name

    fn FillStyle::name(self : FillStyle) -> String

    The rough.js name: "hachure", "cross-hatch", "zigzag-line", ...

    Generator

    pub struct Generator {
    default_options : ResolvedOptions
    }

    Generates Drawables: rough.js' RoughGenerator (rough.generator()).

    Generator::arc

    fn Generator::arc(self : Generator, x : Double, y : Double, width : Double, height : Double, start : Double, stop : Double, closed? : Bool, options? : Options) -> Drawable

    An arc of the ellipse centered at (x, y), from angle start to stop (radians). closed draws the two radii and allows a fill.

    Generator::circle

    fn Generator::circle(self : Generator, x : Double, y : Double, diameter : Double, options? : Options) -> Drawable

    A circle centered at (x, y).

    Generator::curve

    fn Generator::curve(self : Generator, points : Array[(Double, Double)], options? : Options) -> Drawable

    A smooth curve through points.

    Generator::curves

    fn Generator::curves(self : Generator, points_list : Array[Array[(Double, Double)]], options? : Options) -> Drawable

    Several curves drawn as one shape (rough.js' curve(Point[][])).

    Generator::ellipse

    fn Generator::ellipse(self : Generator, x : Double, y : Double, width : Double, height : Double, options? : Options) -> Drawable

    An ellipse centered at (x, y).

    Generator::line

    fn Generator::line(self : Generator, x1 : Double, y1 : Double, x2 : Double, y2 : Double, options? : Options) -> Drawable

    A line from (x1, y1) to (x2, y2).

    Generator::linear_path

    fn Generator::linear_path(self : Generator, points : Array[(Double, Double)], options? : Options) -> Drawable

    An open polyline through points.

    Generator::new

    rough.generator({ options }). source replaces Math.random() (seed 0, dot positions, hachure fallback); the default is RandomSource::default(), a fixed-seed Park-Miller sequence.

    Generator::new_seed

    fn Generator::new_seed(self : Generator) -> Int

    RoughGenerator.newSeed(): a random seed in [0, 2^31) from the generator's random source.

    Generator::ops_to_path

    fn Generator::ops_to_path(self : Generator, drawing : OpSet, fixed_decimals? : Int) -> String

    opsToPath(drawing, fixedDecimals): SVG path data for an op set. With fixed_decimals, numbers are rounded like +n.toFixed(fixed_decimals).

    Generator::path

    fn Generator::path(self : Generator, d : StringView, options? : Options) -> Drawable raise
    PathError

    The shape described by SVG path data d. Raises on malformed data, where rough.js throws (or never returns).

    Generator::polygon

    fn Generator::polygon(self : Generator, points : Array[(Double, Double)], options? : Options) -> Drawable

    A closed polygon through points.

    Generator::rectangle

    fn Generator::rectangle(self : Generator, x : Double, y : Double, width : Double, height : Double, options? : Options) -> Drawable

    A rectangle with top-left corner (x, y).

    Generator::to_paths

    fn Generator::to_paths(self : Generator, drawable : Drawable) -> Array[PathInfo]

    toPaths(drawable): one PathInfo per op set.
    pub(all) enum Op {
    Move(Double, Double)
    LineTo(Double, Double)
    BCurveTo(Double, Double, Double, Double, Double, Double)
    } derive(Eq,
    Debug
    )

    One drawing operation of an OpSet.

    Op::data

    fn Op::data(self : Op) -> Array[Double]

    The op's data array as in rough.js.

    Op::name

    fn Op::name(self : Op) -> String

    The rough.js op name: "move", "lineTo" or "bcurveTo".

    OpSet

    pub(all) struct OpSet {
    kind : OpSetType
    ops : Array[Op]
    } derive(Eq,
    Debug
    )

    A list of ops painted together.

    OpSetType

    pub(all) enum OpSetType {
    Path
    FillPath
    FillSketch
    } derive(Eq,
    Debug
    )

    How an OpSet is meant to be painted.

    OpSetType::name

    fn OpSetType::name(self : OpSetType) -> String

    The rough.js name: "path", "fillPath" or "fillSketch".

    Options

    pub(all) struct Options {
    max_randomness_offset : Double?
    roughness : Double?
    bowing : Double?
    stroke : String?
    stroke_width : Double?
    curve_fitting : Double?
    curve_tightness : Double?
    curve_step_count : Double?
    fill : String?
    fill_style : FillStyle?
    fill_weight : Double?
    hachure_angle : Double?
    hachure_gap : Double?
    simplification : Double?
    dash_offset : Double?
    dash_gap : Double?
    zigzag_offset : Double?
    seed : Int?
    stroke_line_dash : Array[Double]?
    stroke_line_dash_offset : Double?
    fill_line_dash : Array[Double]?
    fill_line_dash_offset : Double?
    disable_multi_stroke : Bool?
    disable_multi_stroke_fill : Bool?
    preserve_vertices : Bool?
    fixed_decimal_place_digits : Int?
    fill_shape_roughness_gain : Double?
    }

    Drawing options; None fields take the generator's defaults. This is rough.js' Options, with the same meaning for every field.

    Options::new

    fn Options::new(max_randomness_offset? : Double, roughness? : Double, bowing? : Double, stroke? : String, stroke_width? : Double, curve_fitting? : Double, curve_tightness? : Double, curve_step_count? : Double, fill? : String, fill_style? : FillStyle, fill_weight? : Double, hachure_angle? : Double, hachure_gap? : Double, simplification? : Double, dash_offset? : Double, dash_gap? : Double, zigzag_offset? : Double, seed? : Int, stroke_line_dash? : Array[Double], stroke_line_dash_offset? : Double, fill_line_dash? : Array[Double], fill_line_dash_offset? : Double, disable_multi_stroke? : Bool, disable_multi_stroke_fill? : Bool, preserve_vertices? : Bool, fixed_decimal_place_digits? : Int, fill_shape_roughness_gain? : Double) -> Options

    Builds Options from labelled arguments, e.g. Options::new(roughness=2.0, fill="red", fill_style=CrossHatch, seed=7).

    PathInfo

    pub(all) struct PathInfo {
    d : String
    stroke : String
    stroke_width : Double
    fill : String?
    } derive(Eq,
    Debug
    )

    PathInfo: one SVG path (d plus paint attributes), as returned by Generator::to_paths.

    ResolvedOptions

    pub struct ResolvedOptions {
    max_randomness_offset : Double
    roughness : Double
    bowing : Double
    stroke : String
    stroke_width : Double
    curve_fitting : Double
    curve_tightness : Double
    curve_step_count : Double
    fill : String?
    fill_style : FillStyle
    fill_weight : Double
    hachure_angle : Double
    hachure_gap : Double
    simplification : Double?
    dash_offset : Double
    dash_gap : Double
    zigzag_offset : Double
    seed : Int
    stroke_line_dash : Array[Double]?
    stroke_line_dash_offset : Double?
    fill_line_dash : Array[Double]?
    fill_line_dash_offset : Double?
    disable_multi_stroke : Bool
    disable_multi_stroke_fill : Bool
    preserve_vertices : Bool
    fixed_decimal_place_digits : Int?
    fill_shape_roughness_gain : Double
    // private fields
    }

    Options with every default applied: rough.js' ResolvedOptions.

    Like the JavaScript object, it also carries the lazily created random number generator. Copies made while drawing ({ ...o, ... } in rough.js) share it if it already exists and create their own otherwise, and a generator's default options keep theirs across calls; both behaviours are reproduced because they decide which random numbers each shape gets.

    ResolvedOptions::random_source

    The source of the Math.random() replacements used while drawing with these options.

    Shape

    pub(all) enum Shape {
    Line
    Rectangle
    Ellipse
    Circle
    LinearPath
    Polygon
    Arc
    Curve
    Path
    } derive(Eq,
    Debug
    )

    The kind of shape a Drawable was generated from.

    Shape::name

    fn Shape::name(self : Shape) -> String

    The rough.js name: "line", "rectangle", "linearPath", ...

    ops_to_path

    fn ops_to_path(drawing : OpSet, fixed_decimals? : Int) -> String

    opsToPath (see Generator::ops_to_path).

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io