All Projects → microbium → regl-line-builder

microbium / regl-line-builder

Licence: other
Draw pretty lines in WebGL with the Canvas2D API.

Programming Languages

javascript
184084 projects - #8 most used programming language
GLSL
2045 projects
shell
77523 projects

Labels

Projects that are alternatives of or similar to regl-line-builder

citibike-trips
Visualizing citibike trips with webgl
Stars: ✭ 54 (+92.86%)
Mutual labels:  regl
planar proj shadows
Demo of Planar Projected Shadows in regl
Stars: ✭ 31 (+10.71%)
Mutual labels:  regl
generative
Creative coding experiments
Stars: ✭ 71 (+153.57%)
Mutual labels:  regl
webgl-regl-fluid-base
Regl base for webgl fluid simulations
Stars: ✭ 14 (-50%)
Mutual labels:  regl
regl-line
Flat 2D and 3D line rending with Regl for WebGL
Stars: ✭ 44 (+57.14%)
Mutual labels:  regl
regl-map-animation
Configurable WebGL animation showing a map transitioning into a bar chart
Stars: ✭ 20 (-28.57%)
Mutual labels:  regl
Plotly.js
Open-source JavaScript charting library behind Plotly and Dash
Stars: ✭ 14,268 (+50857.14%)
Mutual labels:  regl
Plotly.py
The interactive graphing library for Python (includes Plotly Express) ✨
Stars: ✭ 10,701 (+38117.86%)
Mutual labels:  regl
Regl
👑 Functional WebGL
Stars: ✭ 4,412 (+15657.14%)
Mutual labels:  regl

REGL LineBuilder

Stability Build Status Code Style File Size

Pretty Face

Draw pretty lines in WebGL with the Canvas2D API.

Example

import createREGL from 'regl'
import { mat4 } from 'gl-matrix'
import { LineBuilder } from 'regl-line-builder'

const regl = createREGL()
const setupCamera = regl({
  uniforms: {
    view: mat4.identity([]),
    projection: ({ viewportWidth, viewportHeight }) => {
      const w = viewportWidth / 2
      const h = viewportHeight / 2
      return mat4.ortho([], -w, w, -h, h, 0, 10)
    }
  }
})

const lines = LineBuilder.create(regl, {
  bufferSize: 300
})
const ctx = lines.getContext()

ctx.save()
ctx.rotate(-Math.PI / 4)
ctx.lineWidth = 20
ctx.strokeStyle = '#fff000'
ctx.beginPath()
ctx.moveTo(300, 300)
ctx.lineTo(-300, -300)
ctx.lineTo(-300, -500)
ctx.lineTo(300, -300)
ctx.closePath()
ctx.stroke()
ctx.strokeRect(-500, 700, 1000, 1400)
ctx.restore()

ctx.rotate(Math.PI / 4)
ctx.lineWidth = 10
ctx.beginPath()
ctx.moveTo(-300, 300)
ctx.lineTo(300, -300)
ctx.lineTo(300, -500)
ctx.lineTo(-300, -300)
ctx.closePath()
ctx.stroke()
ctx.strokeRect(-500, 700, 1000, 1400)

regl.frame(({ tick }) => {
  const { sin } = Math
  const t0 = sin(tick * 0.1) * 0.5 + 0.5

  setupCamera(() => {
    regl.clear({
      color: [1, 1, 1, 1],
      depth: 1
    })

    lines.draw({
      model: mat4.identity([]),
      tint: [1, 1, 1, 1],
      thickness: 1 + t0 * 0.5,
      miterLimit: 12
    })
  })
})

Install

npm install regl-line-builder --save

License

(c) 2017 Jay Weeks. MIT License
(c) 2015 Matt DesLauriers where noted. MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].