# gl-clear

> A helper WebGL module for clearing the current buffer – extracted from [@mikolalysenko](http://github.com/mikolalysenko)'s [gl-now](http://github.com/mikolalysenko/gl-now).

Latest version **2.0.0** (published 2015-01-11) · MIT license · 0 weekly downloads

## Install

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

## 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.0 |
| Published | 2015-01-11 |
| First published | 2014-05-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Hugh Kennedy |
| Maintainers | hughsk |
| Keywords | gl, webgl, clear, buffer, screen, color, depth, stencil |

## Links

- npm: https://www.npmjs.com/package/gl-clear
- Repository: https://github.com/hughsk/gl-clear
- Issues: https://github.com/hughsk/gl-clear/issues
- npm.io page: https://npm.io/package/gl-clear

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2015-01-11
- 1.0.0 — 2014-11-10
- 0.0.1 — 2014-07-29
- 0.0.0 — 2014-05-12

## README

# gl-clear [![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)

A helper WebGL module for clearing the current buffer – extracted from
[@mikolalysenko](http://github.com/mikolalysenko)'s
[gl-now](http://github.com/mikolalysenko/gl-now).

## Usage

[![NPM](https://nodei.co/npm/gl-clear.png)](https://nodei.co/npm/gl-clear/)

### `clear = glClear(options)`

Creates a clear function for you, accepting the following options:

* `color`: An RGBA array for the colors to clear the buffer to, between 0 and 1.
  Set to `false` to disable.
* `depth`: A single value to clear the depth buffer to. Set to `false` to disable.
* `stencil`: A single value to clear the stencil buffer to, disabled by default.

### `clear(gl)`

Clears the current buffer on the `gl` context.

### `clear.color = color`

Updates the clear color. Set to `false` to disable.

### `clear.depth = depth`

Updates the depth value to clear to. Set to `false` to disable.

### `clear.stencil = stencil`

Updates the stencil value to clear to. Set to `false` to disable.

## Alternatives

This module is intended as a small shorthand to WebGL's clear methods.
Thankfully clearing is a simple procedure so you are also welcome to fall back
onto WebGL's clear methods if `gl-clear` doesn't meet your needs. For example:

``` javascript
// clear the screen red, and clear the depth buffer:
gl.clearColor(1, 0, 0, 1)
gl.clearDepth(1)
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
```

If you've written your own clear module, let us know and we'll link to it
here!

## License

MIT. See [LICENSE.md](http://github.com/hughsk/gl-clear/blob/master/LICENSE.md) for details.

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