npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

regl-line2d

v3.1.3

Published

Draw polyline with regl

Downloads

893,027

Readme

regl-line2d experimental

Draw polyline with regl.

regl-line2d

Remake on gl-line2d:

  • GPU join calculation.
  • Bevel, round and rectangular joins.
  • Dash patterns.
  • Self-overlapping and sharp angles cases.
  • Multiline rendering.
  • Float64 precision.
  • <polyline>-compatible API

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.

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.

Related

Similar

License

(c) 2017 Dima Yv. MIT License

Development supported by plot.ly.