draw-triangles-2d
Draws indexed triangles from a simplicial complex using Canvas2D context.
Positions and cells look like this:
positions: 2525 50 50 ... cells: 012 123 ...
Demo:
var drawTriangles = var path = 25 25 40 30 50 75 125 15 //get a thick polylinevar mesh = thickness: 20 miterLimit: 15 { ctx ctx ctxstrokeStyle = 'black' ctxlineJoin = 'bevel' ctx}
Simplicial complexes are a common ground between various modules, such as triangulate-contours, extrude-polyline, etc.
Usage
draw(context, positions, cells[, start, end])
Draws the 2D positions and triangle cells (i.e. indices into positions) to the given context. You can specify start
(inclusive) and end
(exclusive) indices to only render a sub range of the cells. These values defualt to 0 and the length of cells
, respectively.
License
MIT, see LICENSE.md for details.