Documentation / spryte / lines
Function: lines()
lines(
draw,segments,count?,o?,each?):void
Defined in: lines.ts:82
Many lines in one call: graph edges, grids, vector fields, trails. segments is x1, y1, x2, y2 per line. On WebGL2 it's one draw call, and a Float32Array is uploaded as is, with no JavaScript work per line; the GPU turns each line into a quad. Each line lands on the pixels line() draws with the same values. options apply to every line; each adds a width or colour per line (multiplied with options).
import { lines } from "spryte";
lines(draw, edges, edgeCount, { color: "#ffffff20" });
lines(draw, edges, edgeCount, { width: 2 }, { color: edgeColors }); // edgeColors: Uint32Array of 0xRRGGBBAAcount is clamped to the shortest array; a NaN or negative count draws nothing. Zero-length lines draw nothing. Custom shaders (withShader) don't apply on WebGL2. On the Canvas 2D fallback each line is drawn with draw.line(). A separate import, like polyline, so apps that don't draw lines don't include it. Since spryte 0.15.
Parameters
draw
segments
ArrayLike<number>
count?
number = ...
o?
LinesOptions = {}
each?
Returns
void