1.0.0 • Published 10 years ago
gl-checker-background v1.0.0
gl-checker-background
Draws a checkered full-screen background quad, ideal for quick demos.
var createBackground = require('gl-checker-background')
var background = createBackground(gl, {
colors: [
[0x50,0x50,0x50,0xff],
[0x46,0x46,0x46,0xff]
]
})
function render() {
...
background.draw()
}
Usage
bg = createBackground(gl[, opt])
Creates a checkered background with some options.
shader
a shader to use, defaults to a new shader with gl-basic-shaderbatch
a gl-sprite-batch to use, defaults to a new one with a capacity of 1 spritecolors
an array of RGBA colors (in bytes) to use for the two tonessize
the desired square size of the checker pixel, default32 * 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.
1.0.0
10 years ago