Socket
Socket
Sign inDemoInstall

get-2d-context

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-2d-context

get-2d-context


Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

usage

var container = document.querySelector('#myContainer')

var options = {
    responsive: true,
    fullscreen: false
}

// a canvas will be appended to container
// if container is left unspecified the default container is document.body
// the width and height of canvas is equal to container
var ctx = get2dContext(container, options)

if(!ctx) {
    // canvas is not supported on this device
} else {
    // magic!!1
}

##options

  • responsive
    • is true by default
    • keeps canvas.width and .height equal to container
  • fullscreen
    • is false by default
    • use only when container === document.body
    • sets document.body.width = window.innerWidth && .height = window.innerHeigght
    • applies css styles to document.body (overflow: 'hidden', margin: 0, padding: 0)

Keywords

FAQs

Package last updated on 20 Dec 2014

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

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc