
Product
Announcing Precomputed Reachability Analysis in Socket
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
regl-line2d
Advanced tools
Draw polyline with regl.
Remake on gl-line2d:
<polyline>
-compatible APIDemo.
let regl = require('regl')({extensions: 'angle_instanced_arrays'})
let line2d = require('regl-line2d')(regl)
// draw red triangle
line2d.render({ thickness: 4, points: [0,0, 1,1, 1,0], close: true, color: 'red' })
line2d.render(options|list?)
Draw line or multiple lines and update options, once per frame at most.
Option | Default | Description |
---|---|---|
positions , points , data | [] | Point coordinates, eg. [0,0, 1,1, 0,2, 1,-1] or [[0,0], [1,1], [0,2], [1,-1]] . |
color , colors , stroke | black | CSS color string or an array with 0..1 values, eg. 'red' or [0, 0, 0, 1] . |
fill | null | Fill area enclosed by line with defined color. |
opacity | 1 | Line transparency regardless of color. |
thickness , lineWidth , width , strokeWidth | 1 | Line width in px. |
dashes , dash , dasharray | null | Array with dash lengths in px, altering color/space pairs, ie. [2,10, 5,10, ...] . null corresponds to solid line. |
join , type | bevel | Join style: 'rect' , 'round' , 'bevel' . Applied to caps too. |
miterLimit | 1 | Max ratio of the join length to the thickness. |
close , closed , closePath | false | Connect last point with the first point with a segment. |
overlay | false | Enable overlay of line segments. |
range , dataBox | null | Visible data range. |
viewport , viewBox | null | Area within canvas, an array [left, top, right, bottom] or an object {x, y, w, h} or {left, top, bottom, right} . |
To render multiple lines pass an array with options for every line as list
:
line2d.render([
{thickness: 2, points: [0,0, 1,1], color: 'blue'},
{thickness: 2, points: [0,1, 1,0], color: 'blue'}
])
null
argument will destroy line2d
instance and dispose resources.
line2d.update(options|list)
Update line(s) not incurring redraw.
line2d.draw(id?)
Draw lines from last updated options. id
integer can specify a single line from the list
to redraw.
line2d.destroy()
Dispose line2d
and associated resources.
(c) 2017 Dima Yv. MIT License
Development supported by plot.ly.
FAQs
Draw polyline with regl
The npm package regl-line2d receives a total of 223,378 weekly downloads. As such, regl-line2d popularity was classified as popular.
We found that regl-line2d demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 15 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.