{"name":"canvas-fit","version":"0.0.0","description":"Small module for fitting a canvas element within the bounds of its parent.","main":"index.js","scripts":{"test":"beefy test.js --open"},"repository":{"type":"git","url":"git://github.com/hughsk/canvas-fit.git"},"author":{"name":"Hugh Kennedy","email":"hughskennedy@gmail.com","url":"http://hughsk.io/"},"license":"MIT","bugs":{"url":"https://github.com/hughsk/canvas-fit/issues"},"homepage":"https://github.com/hughsk/canvas-fit","dependencies":{},"devDependencies":{"beefy":"^1.1.0","raf":"^0.1.3"},"keywords":["canvas","fit","screen","window","browser","stretch","resize"],"_id":"canvas-fit@0.0.0","_shasum":"5fbfc34736f532d6fd2e474ff4493c3bd4b5415f","_from":".","_npmVersion":"1.4.10","_npmUser":{"name":"hughsk","email":"hughskennedy@gmail.com"},"maintainers":[{"name":"hughsk","email":"hughskennedy@gmail.com"}],"dist":{"shasum":"5fbfc34736f532d6fd2e474ff4493c3bd4b5415f","tarball":"http://registry-npm.ywwl.com/canvas-fit/download/canvas-fit-0.0.0.tgz","integrity":"sha512-nKe3B2VQFsF4/2uRPAwrCY5L1UzKAlH86msRCz933xQzLVkrDt4U8Mu14OOidCKdI/h9PKF0HWrYLgBzdam2rA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCD6f9pbRtD88xR7cJLBGiUYk97AROa5rpuWdneTOcFiwIhANZYB+fV18vvv+KJ3bu1QH6CePqw3KWxm2e+xBl9ElS+"}],"size":1916,"noattachment":false,"key":"/canvas-fit/-/canvas-fit-0.0.0.tgz"},"directories":{},"readme":"# canvas-fit [![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)\n\nSmall module for fitting a canvas element within the bounds of its parent.\nUseful, for example, for making a canvas fill the screen. Works with SVG\nelements too!\n\n## Usage\n\n[![NPM](https://nodei.co/npm/canvas-fit.png)](https://nodei.co/npm/canvas-fit/)\n\n### resize = fit(canvas[, parent[, scale]])\n\nCreates a `resize` function for your `canvas` element. Calling this function\nwill resize the canvas to fit its parent element.\n\nHere's a simple example to make your canvas update its dimensions when\nresizing the window:\n\n``` javascript\nvar fit = require('canvas-fit')\nvar canvas = document.createElement('canvas')\n\nwindow.addEventListener('resize', fit(canvas), false)\n```\n\nYou might want to override the `parent` element that the canvas should be\nfitting within: in which case, pass that element in as your second argument:\n\n``` javascript\nwindow.addEventListener('resize'\n  , fit(canvas, window)\n  , false\n)\n```\n\nYou can also set the scale of the canvas element relative to its styled size\non the page using the `scale` argument – for example, passing in\n`window.devicePixelRatio` here will scale the canvas resolution up on retina\ndisplays.\n\n\n### `resize.scale = <Number>`\n\nDynamically change the canvas' target `scale`. Note that you still need to\nmanually trigger a resize after doing this.\n\n\n### `resize.parent = <DOMElement>`\n\nDynamically change the canvas' `parent` element. Note that you still need\nto manually trigger a resize after doing this.\n\n### `resize.parent = () => [width, height]`\n\nInstead of filling a given element, explicitly set the width and height\nof the canvas. Note that this value will still be scaled up according\nto `resize.scale`\n\n``` javascript\nresize.parent = function() {\n  return [ window.innerWidth - 300, window.innerHeight ]\n}\n```\n\n## License\n\nMIT. See [LICENSE.md](http://github.com/hughsk/canvas-fit/blob/master/LICENSE.md) for details.\n","publish_time":1400017740022,"_cnpm_publish_time":1400017740022,"dist-tags":{"latest":"1.5.0"}}