@huukhanhnguyen/geometry / namespaces/Curve2d
namespaces/Curve2d
addPoints
constaddPoints: (shape_json,points) =>string=wasm.path2d_add_points
addShape's point-array overload: auto-closes when the first and last points coincide, and joins onto an existing open chain when an endpoint matches.
Parameters
shape_json
string
points
Float64Array
Returns
string
addShape
constaddShape: (shape_json,contour_json) =>string=wasm.path2d_add_shape
Append one contour (ContourJson wire) to a Path2d.
Parameters
shape_json
string
contour_json
string
Returns
string
area
constarea: (shape_json,tolerance) =>number=wasm.path2d_area
Parameters
shape_json
string
tolerance
number
Returns
number
boolean
constboolean: (subject_json,clip_json,operation,tolerance) =>string=wasm.path2d_boolean
Parameters
subject_json
string
clip_json
string
operation
string
tolerance
number
Returns
string
boundingBox
constboundingBox: (shape_json) =>Float64Array=wasm.path2d_bounding_box
[minX, minY, maxX, maxY].
Parameters
shape_json
string
Returns
Float64Array
chamfer
constchamfer: (shape_json,distance1,distance2) =>string=wasm.path2d_chamfer
Parameters
shape_json
string
distance1
number
distance2
number
Returns
string
circle
constcircle: (cx,cy,radius,use_transformation,transformation) =>string=wasm.path2d_circle
Parameters
cx
number
cy
number
radius
number
use_transformation
boolean
transformation
Float64Array
Returns
string
cleanup
constcleanup: (shape_json,tolerance) =>string=wasm.path2d_cleanup
Parameters
shape_json
string
tolerance
number
Returns
string
containsPoint
constcontainsPoint: (shape_json,x,y,tolerance) =>boolean=wasm.path2d_contains_point
Parameters
shape_json
string
x
number
y
number
tolerance
number
Returns
boolean
ellipse
constellipse: (cx,cy,x_axis_x,x_axis_y,y_axis_x,y_axis_y,use_transformation,transformation) =>string=wasm.path2d_ellipse
Parameters
cx
number
cy
number
x_axis_x
number
x_axis_y
number
y_axis_x
number
y_axis_y
number
use_transformation
boolean
transformation
Float64Array
Returns
string
fillet
constfillet: (shape_json,radius) =>string=wasm.path2d_fillet
Parameters
shape_json
string
radius
number
Returns
string
filletVertices
constfilletVertices: (shape_json,radius,vertex_indices) =>string=wasm.path2d_fillet_vertices
Fillet only the listed vertex indices. An empty list fillets every corner (same as path2d_fillet).
Parameters
shape_json
string
radius
number
vertex_indices
Uint32Array
Returns
string
fromPolyline
constfromPolyline: (points,use_transformation,transformation) =>string=wasm.path2d_from_polyline
Parameters
points
Float64Array
use_transformation
boolean
transformation
Float64Array
Returns
string
fromRegions
constfromRegions: (regions_json,use_transformation,transformation) =>string=wasm.path2d_from_regions
regions_json is a JSON array of arrays of [x, y] rings.
Parameters
regions_json
string
use_transformation
boolean
transformation
Float64Array
Returns
string
fromRings
constfromRings: (rings_json,use_transformation,transformation) =>string=wasm.path2d_from_rings
rings_json is a JSON array of rings, each ring an array of [x, y] pairs (NOT a flat [x, y, ...] run — that is what the deserializer refuses).
Parameters
rings_json
string
use_transformation
boolean
transformation
Float64Array
Returns
string
isClosed
constisClosed: (shape_json) =>boolean=wasm.path2d_is_closed
Parameters
shape_json
string
Returns
boolean
length
constlength: (shape_json) =>number=wasm.path2d_length
Parameters
shape_json
string
Returns
number
offset
constoffset: (shape_json,distance,cap) =>string=wasm.path2d_offset
Signed offset: positive dilates, negative erodes, and any OPEN chain is stroked by |distance| with the given cap — "butt" / "square" / anything else, which the TS default reads as round, the same rule parse_operation follows for the boolean op.
Parameters
shape_json
string
distance
number
cap
string
Returns
string
plane
constplane: (shape_json) =>Float64Array=wasm.path2d_plane
[nx, ny, nz, constant] — the plane the 3D placement puts this region on.
Parameters
shape_json
string
Returns
Float64Array
rectangle
constrectangle: (cx,cy,width,height,use_transformation,transformation) =>string=wasm.path2d_rectangle
Parameters
cx
number
cy
number
width
number
height
number
use_transformation
boolean
transformation
Float64Array
Returns
string
regularPolygon
constregularPolygon: (cx,cy,radius,sides,use_transformation,transformation) =>string=wasm.path2d_regular_polygon
Parameters
cx
number
cy
number
radius
number
sides
number
use_transformation
boolean
transformation
Float64Array
Returns
string
reverse
constreverse: (shape_json) =>string=wasm.path2d_reverse
Parameters
shape_json
string
Returns
string
ringSignedArea
constringSignedArea: (ring) =>number=wasm.path2d_ring_signed_area
ringSignedArea on a flat [x, y, ...] ring.
Parameters
ring
Float64Array
Returns
number
roof
constroof: (shape_json,pitch,tolerance) =>Float64Array=wasm.path2d_roof
Raise a roof from the path's straight skeleton. pitch is the roof angle in radians; the packed triangle soup has z = time · tan(pitch).
Parameters
shape_json
string
pitch
number
tolerance
number
Returns
Float64Array
shapeStraightSkeleton
constshapeStraightSkeleton: (shape_json,tolerance) =>string=wasm.path2d_shape_straight_skeleton
Path2d.straightSkeleton(tolerance) — the region's own rings, sampled at tolerance, fed to the same algorithm.
Parameters
shape_json
string
tolerance
number
Returns
string
signedArea
constsignedArea: (shape_json,tolerance) =>number=wasm.path2d_signed_area
Parameters
shape_json
string
tolerance
number
Returns
number
splitByLine
constsplitByLine: (shape_json,ox,oy,dx,dy) =>string=wasm.path2d_split_by_line
Split the path by the infinite line through (ox,oy) in direction (dx,dy). Returns JSON [positive, negative] Path2d documents.
Parameters
shape_json
string
ox
number
oy
number
dx
number
dy
number
Returns
string
straightSkeleton
conststraightSkeleton: (loops_json) =>string=wasm.path2d_straight_skeleton
computeStraightSkeleton(loops) — loops_json is a JSON array of rings, each a JSON array of [x, y] pairs (the shape path2d_from_rings takes). Returns the StraightSkeleton wire object: { nodes: [{ point: [x, y], time }], arcs: [{ a, b }], faces: [[…]] }.
Parameters
loops_json
string
Returns
string
tessellate
consttessellate: (shape_json,tolerance) =>string=wasm.path2d_tessellate
One sampled polyline per shape, as a JSON array of flat [x, y, ...] rings.
Parameters
shape_json
string
tolerance
number
Returns
string
thicken
constthicken: (shape_json,distance,join_type,end_type,miter_limit,merge_connected) =>string=wasm.path2d_thicken
Stroke by distance: open chains capped with end_type, closed rings turned into hollow bands, everything unioned into one region. join_type is "miter" / "square" / anything else, which the TS default reads as round; end_type follows path2d_offset's cap spelling. merge_connected pre-stitches open paths sharing an endpoint into one chain, so fragments of one original path stroke without stray internal caps — pass false for inputs that merely TOUCH by design.
Parameters
shape_json
string
distance
number
join_type
string
end_type
string
miter_limit
number
merge_connected
boolean
Returns
string
toNurbsCurves
consttoNurbsCurves: (shape_json) =>string=wasm.path2d_to_nurbs_curves
A JSON array of NurbsCurveJSON, one per shape.
Parameters
shape_json
string
Returns
string
toRegions
consttoRegions: (shape_json,tolerance) =>string=wasm.path2d_to_regions
Rings grouped into polygons (outer + holes) by orientation, as a JSON array of arrays of [x, y] pairs.
Parameters
shape_json
string
tolerance
number
Returns
string
toRings
consttoRings: (shape_json,tolerance) =>string=wasm.path2d_to_rings
Sampled rings (closed; first and last do NOT repeat).
Parameters
shape_json
string
tolerance
number
Returns
string
transform
consttransform: (shape_json,elements) =>string=wasm.path2d_transform
Parameters
shape_json
string
elements
Float64Array
Returns
string
triangulate
consttriangulate: (shape_json,tolerance) =>Float64Array=wasm.path2d_triangulate
Group + CDT over the sampled rings, PACKED into one Float64Array: a one-value header holding the vertex-coordinate count, then that many coordinates (x, y, …), then the triangle indices. Indices ride as doubles, exact for every index a real region can hold — the same rule mesh/wasm.rs::pack_triangle_mesh follows, and for the same reason: two parallel buffers, one call.
Parameters
shape_json
string
tolerance
number
Returns
Float64Array
unionAll
constunionAll: (regions_json,tolerance,fill_rule) =>string=wasm.path2d_union_all
fill_rule is "evenodd" (the default) or "nonzero". regions_json is a JSON array of Path2d.
Parameters
regions_json
string
tolerance
number
fill_rule
string
Returns
string
voronoi
constvoronoi: (shape_json,options_json) =>string=wasm.path2d_voronoi
options_json is a VoronoiOptions — every field optional, TS defaults.
Parameters
shape_json
string
options_json
string
Returns
string