You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

org.webjars.npm:webgl-context

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

org.webjars.npm:webgl-context

WebJar for webgl-context


Version published
Maintainers
1

Readme

Source

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.

FAQs

Package last updated on 10 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc