Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

regl-line2d

Package Overview
Dependencies
Maintainers
15
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regl-line2d

Draw polyline with regl

  • 3.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
189K
increased by4.15%
Maintainers
15
Weekly downloads
 
Created
Source

regl-line2d experimental

Draw polyline with regl.

regl-line2d

Remake on gl-line2d:

Demo.

Usage

npm install regl-line2d

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.

OptionDefaultDescription
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, strokeblackCSS color string or an array with 0..1 values, eg. 'red' or [0, 0, 0, 1].
fillnullFill area enclosed by line with defined color.
opacity1Line transparency regardless of color.
thickness, lineWidth, width, strokeWidth1Line width in px.
dashes, dash, dasharraynullArray with dash lengths in px, altering color/space pairs, ie. [2,10, 5,10, ...]. null corresponds to solid line.
join, typebevelJoin style: 'rect', 'round', 'bevel'. Applied to caps too.
miterLimit1Max ratio of the join length to the thickness.
close, closed, closePathfalseConnect last point with the first point with a segment.
overlayfalseEnable overlay of line segments.
range, dataBoxnullVisible data range.
viewport, viewBoxnullArea 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.

Similar

License

(c) 2017 Dima Yv. MIT License

Development supported by plot.ly.

Keywords

FAQs

Package last updated on 14 Feb 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc