JSPM

gl-checker-background

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q30976F
  • License MIT

checkered full-screen background for GL demos

Package Exports

  • gl-checker-background

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gl-checker-background) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

gl-checker-background

experimental

Draws a checkered full-screen background quad, ideal for quick demos.

img

var createBackground = require('gl-checker-background')

var background = createBackground(gl, {
    colors: [
        [0x50,0x50,0x50,0xff],
        [0x46,0x46,0x46,0xff]
    ]
})

function render() {
    ...
    background.draw()
}

Usage

NPM

bg = createBackground(gl[, opt])

Creates a checkered background with some options.

  • shader a shader to use, defaults to a new shader with gl-basic-shader
  • batch a gl-sprite-batch to use, defaults to a new one with a capacity of 1 sprite
  • colors an array of RGBA colors (in bytes) to use for the two tones
  • size the desired square size of the checker pixel, default 32 * devicePixelRatio

bg.draw([width, height])

Draws the sprite as a full-screen quad, using the width, height to determine the repeating texture coordinates of the checker tile. Defaults to using the gl canvas width and height.

bg.dispose()

Disposes of the texture, batch and shader associated with this background.

License

MIT, see LICENSE.md for details.