# gl-toy

> Create quick WebGL demo's using glslify

Latest version **2.0.3** (published 2016-01-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install gl-toy
pnpm add gl-toy
yarn add gl-toy
bun add gl-toy
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2016-01-01 |
| First published | 2014-12-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 19 |
| Maintainers | chrisdickinson, hughsk, mattdesl, mikolalysenko, rezaali, substack, thibauts, yoshuawuyts |
| Keywords | glslify, webgl, shader, shaders, boilerplate, kickstart, shadertoy, ecosystem:stackgl |

## Links

- npm: https://www.npmjs.com/package/gl-toy
- Repository: https://github.com/stackgl/gl-toy
- Homepage: https://github.com/stackgl/gl-toy#readme
- Issues: https://github.com/stackgl/gl-toy/issues
- npm.io page: https://npm.io/package/gl-toy

## Dependencies (5)

- [babelify](https://npm.io/package/babelify.md) ^6.0.2
- [gl-shader](https://npm.io/package/gl-shader.md) ^4.0.1
- [canvas-fit](https://npm.io/package/canvas-fit.md) ^1.2.0
- [gl-context](https://npm.io/package/gl-context.md) ^0.1.1
- [a-big-triangle](https://npm.io/package/a-big-triangle.md) ^1.0.0

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 2.0.3 (latest) — 2016-01-01
- 2.0.2 — 2015-04-25
- 2.0.1 — 2015-04-25
- 2.0.0 — 2015-04-25
- 1.0.0 — 2014-12-08

## README

# gl-toy
[![NPM version][npm-image]][npm-url]
[![Downloads][downloads-image]][downloads-url]

Create quick GLSL fragment shader demos.

## Installation
```bash
$ npm install gl-toy
```

## Usage
```js
var glslify = require('glslify')
var toy     = require('gl-toy')

var shader = glslify('./shader.frag')
var start  = Date.now()

toy(shader, function(gl, shader) {
  shader.uniforms.uScreenSize = [gl.drawingBufferWidth, gl.drawingBufferHeight]
  shader.uniforms.uTime = Date.now() - start
})
```
With [beefy](http://ghub.io/beefy) installed:
```js
$ beefy ./index.js
```

### toy = glToy(frag, update)
Creates a new shader renderer, attaching it to `document.body` and making
it fill the screen.

`frag` should be a fragment shader string you'd like to render using
[`a-big-triangle`](http://ghub.io/a-big-triangle).

`update(gl, shader)` is called before drawing to the screen so that you
can update uniforms being passed into the program. Here, `gl` is a
`WebGLRenderingContext` and `shader` is an instance of
[`gl-shader`](http://ghub.io/gl-shader).

### toy.update(frag)

Updates the current fragment shader with the new `frag`
string.

### toy.resize()

Resizes the canvas to fit within its parent element, using
[`canvas-fit`](http://ghub.io/canvas-fit).

### toy.canvas

A reference to `gl-toy`'s canvas element.

### toy.gl

A reference to `gl-toy`'s `WebGLRenderingContext`.

### toy.shader

A reference to `gl-toy`'s instance of
[`gl-shader`](http://ghub.io/gl-shader).

## Why?
WebGL and glslify can be a bit tricky to set up. This makes it easier to get
something working quickly. It might not suit all use cases, but then again:
neither does [shadertoy](https://www.shadertoy.com/).

## Contributors
- [Yoshua Wuyts](https://github.com/yoshuawuyts)
- [Hugh Kennedy](https://github.com/hughsk)

## License
[MIT](https://tldrlegal.com/license/mit-license)

[npm-image]: https://img.shields.io/npm/v/gl-toy.svg?style=flat-square
[npm-url]: https://npmjs.org/package/gl-toy
[downloads-image]: http://img.shields.io/npm/dm/gl-toy.svg?style=flat-square
[downloads-url]: https://npmjs.org/package/gl-toy

---
_Source: https://npm.io/package/gl-toy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
