sayoi7799/moon_excalidraw/shape does not have a README file

    ShapeCache

    pub struct ShapeCache {
    // private fields
    }

    Upstream keeps generated shapes in a cache, and getElementAbsoluteCoords changes behaviour with it: with no cached shape it estimates a line's box from its points, with one it uses the real curve. So the coordinates depend on which shapes were generated before, and that history is part of the output.

    ShapeCache::new

    fn ShapeCache::new() -> ShapeCache

    ShapeCache::store

    Keeps the drawable upstream's ShapeCache.generateElementShape made for e. Later reads use it as it was drawn, not a fresh one made from the points as they are by then.

    absolute_coords

    fn absolute_coords(cache : ShapeCache, e :
    Element
    , map : Map[String,
    Element
    ]) -> (Double, Double, Double, Double, Double, Double)

    getElementAbsoluteCoords: x1, y1, x2, y2, cx, cy, ignoring rotation.

    bound_text

    getBoundTextElement: the first text bound to a container.

    bound_text_position

    LinearElementEditor.getBoundTextElementPosition: a label sits on the middle point, or on the middle of the middle segment.

    common_bounds

    fn common_bounds(cache : ShapeCache, elements : Array[
    Element
    ], map : Map[String,
    Element
    ]) -> (Double, Double, Double, Double)

    getCommonBounds. As upstream, an empty list is the empty box at the origin.

    corner_radius

    fn corner_radius(x : Double, e :
    Element
    ) -> Double

    getCornerRadius of shapes.tsx.

    curve_path_ops

    getCurvePathOps.

    diamond_points

    fn diamond_points(e :
    Element
    ) -> (Double, Double, Double, Double, Double, Double, Double, Double)

    getDiamondPoints: top, right, bottom, left. The +1 is upstream's, to keep the points from being 0.

    element_bounds

    fn element_bounds(cache : ShapeCache, e :
    Element
    , map : Map[String,
    Element
    ]) -> (Double, Double, Double, Double)

    getElementBounds: the box around the element after rotation.

    freedraw_path

    fn freedraw_path(e :
    Element
    ) -> String

    getFreeDrawSvgPath. The editor's last option (the stroke is finished) is always false here: restore clears lastCommittedPoint.

    generate

    The rough.js drawables of an element, in paint order. Text, images and frames have none. canvas_background fills "outline" arrowheads.

    generate_curve

    generateLinearElementShape: the curve drawn for a line or arrow, which is also the first drawable of its shape.

    A closed line with a pattern fill is drawn as a polygon, and rough.js's pattern fills rotate the polygon's points in place and back. That leaves rounding noise in upstream's element.points, which every later calculation then reads, so the element's points are overwritten the same way.

    is_path_a_loop

    fn is_path_a_loop(points : Array[(Double, Double)]) -> Bool

    is_transparent

    fn is_transparent(color : String) -> Bool

    isTransparent of utils.ts.

    rough_options

    generateRoughOptions(element, continuousPath). Every call asks for rough.js 4.6.4 behaviour, the version Excalidraw uses.

    trim_path_decimals

    fn trim_path_decimals(path : String) -> String

    path.replace(/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g, "$1"), the regular expression upstream uses to cut every number with a fraction to two decimals. It truncates, it doesn't round. The core library has no regex engine, so this walks the text the same way a match would: an optional space, an optional capital letter, an optional comma and minus, the integer digits, a dot, up to two digits, and then it drops the rest of the digits, e and -.