# get-2d-context

> get-2d-context

Latest version **1.0.1** (published 2014-12-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install get-2d-context
pnpm add get-2d-context
yarn add get-2d-context
bun add get-2d-context
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2014-12-20 |
| First published | 2014-12-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | olivierrr |
| Maintainers | olivierrr |
| Keywords | canvas, 2d, context, ctx, util |

## Links

- npm: https://www.npmjs.com/package/get-2d-context
- Repository: https://github.com/olivierrr/get-2d-context
- Issues: https://github.com/olivierrr/get-2d-context/issues
- npm.io page: https://npm.io/package/get-2d-context

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2014-12-20
- 1.0.0 — 2014-12-20

## README

## usage

```js
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)

---
_Source: https://npm.io/package/get-2d-context · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
