Necesito Programar Más
    TypeScript icon, indicating that this package has built-in type declarations

    3.4.23 • Public • Published


    npm version npm downloads Twitter Follow

    This project is part of the monorepo.

    For the Clojure version, please visit:


    Functional, polymorphic API for 2D geometry types & SVG generation.

    This project is a partially ported from the Clojure version of the same name. All polymorphic operations built on

    The following operations are provided (many also applicable to shape groups directly and/or perform automatic resampling/conversion if needed):

    Operation Description
    arcLength() compute arc length / perimeter of shape boundary
    area() signed/unsigned surface area
    asCubic() convert shape boundary to cubic bezier segments
    asPath() convert shape to path
    asPolygon() convert shape to polygon
    asPolyline() convert shape to polyline
    asSvg() serialize shape/group/hierarchy to SVG
    bounds() compute bounding box
    center() center shape around origin or point
    centroid() compute shape centroid
    classifyPoint() classify point in relation to shape boundary (in/out)
    clipConvex() clip shape against convex boundary
    closestPoint() compute closest point on shape boundary
    convexHull() compute convex hull (2d only)
    edges() extract edges
    fitIntoBounds() rescale/reposition shapes into a destination boundary
    flip() reverse order (vertices or direction)
    intersects() pairwise shape intersection (various types)
    mapPoint() transform world space point into local shape space
    offset() shape/path offsetting
    pointAt() compute point on shape boundary at parametric position
    pointInside() check if point is inside shape
    resample() resample/convert shape
    rotate() rotate shape
    scale() scale shape (uniformly/non-uniformly)
    scatter() create random points inside a shape boundary
    simplify() simplify shape/boundary (Douglas-Peucker)
    splitAt() split shape/boundary at parametric position
    splitNear() split shape/boundary near world position
    subdivCurve() recursively apply curve subdivision kernel
    tangentAt() compute tangent at parametric position
    tessellate() (recursively) tessellate shape
    transformVertices() apply custom function to each vertex
    transform() apply transformation matrix
    translate() translate shape
    union() compute shape union
    vertices() extract/sample vertices from shape boundary
    volume() compute shape volume (3D only)
    warpPoints() transfer points between the local spaces defined by 2 shapes

    This package acts as a higher-level frontend for most of the following related packages (which are more low-level, lightweight and usable by themselves too):

    Support packages


    STABLE - used in production

    Search or submit any issues for this package


    yarn add

    ES module import:

    <script type="module" src=""></script>

    Skypack documentation

    For Node.js REPL:

    # with flag only for < v16
    node --experimental-repl-await
    > const geom = await import("");

    Package sizes (brotli'd, pre-treeshake): ESM: 11.90 KB


    Usage examples

    Several demos in this repo's /examples directory are using this package.

    A selection:

    Screenshot Description Live demo Source
    Convex hull & shape clipping of 2D polygons Demo Source
    geom-fuzz basic shape & fill examples Demo Source
    Animated, recursive polygon tessellations Demo Source
    Poisson-disk shape-aware sampling, Voronoi & Minimum Spanning Tree visualization Demo Source
    Mouse gesture / stroke analysis, simplification, corner detection Demo Source
    2D Bezier curve-guided particle system Demo Source
    Animated arcs & drawing using hiccup-canvas Demo Source
    Canvas based Immediate Mode GUI components Demo Source
    Animated sine plasma effect visualized using contour lines Demo Source
    2D Poisson-disc sampler with procedural gradient map Demo Source
    Polygon to cubic curve conversion & visualization Demo Source
    Animated Voronoi diagram, cubic splines & SVG download Demo Source
    2D scenegraph & shape picking Demo Source
    2D scenegraph & image map based geometry manipulation Demo Source
    Compute cubic spline position & tangent using Dual Numbers Demo Source
    SVG path parsing & dynamic resampling Demo Source
    3D wireframe textmode demo Demo Source


    Generated API docs



    Karsten Schmidt

    If this project contributes to an academic publication, please cite it as:

      title = "",
      author = "Karsten Schmidt",
      note = "",
      year = 2013


    © 2013 - 2022 Karsten Schmidt // Apache Software License 2.0


    npm i

    DownloadsWeekly Downloads






    Unpacked Size

    257 kB

    Total Files


    Last publish