webgl-context

WebJar for webgl-context

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

webgl-context
Last Version

Last Version

2.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

webgl-context
WebJar for webgl-context
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/mattdesl/webgl-context

Download webgl-context

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/webgl-context/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>webgl-context</artifactId>
    <version>2.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/webgl-context/
implementation 'org.webjars.npm:webgl-context:2.2.0'
// https://jarcasting.com/artifacts/org.webjars.npm/webgl-context/
implementation ("org.webjars.npm:webgl-context:2.2.0")
'org.webjars.npm:webgl-context:jar:2.2.0'
<dependency org="org.webjars.npm" name="webgl-context" rev="2.2.0">
  <artifact name="webgl-context" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='webgl-context', version='2.2.0')
)
libraryDependencies += "org.webjars.npm" % "webgl-context" % "2.2.0"
[org.webjars.npm/webgl-context "2.2.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : get-canvas-context jar [1.0.1,2)

Project Modules

There are no modules declared in this project.

webgl-context

stable

Grabs a WebGLRenderingContext, returning null if it doesn't exist. Similar to 2d-context.

//get a webgl context, will be null if not found
var gl = require('webgl-context')()

if (gl) {
    document.body.appendChild(gl.canvas)
    //do something...
}

Or, with options:

//or with optional settings...
var gl = require('webgl-context')({
    canvas: canvas, //the canvas DOM element to use
    width: 400, //resizes the canvas..
    height: 200, 
    antialias: true //can specify custom attributes here
})

Usage

NPM

ctx = require('webgl-context')([opt])

Gets a new canvas context with optional parameters:

  • canvas a canvas element to use, otherwise creates a new element
  • width a width to set, otherwise no change
  • height a height to set, otherwise no change
  • other attributes are passed to the getContext call, like alpha and antialias

You can then get a reference of the canvas element with ctx.canvas.

See Also

License

MIT, see LICENSE.md for details.

Versions

Version
2.2.0