{"_id":"@blinkmobile/canvas-manipulation","_rev":"10-39e1061df2403602ffe8c67a04b664af","name":"@blinkmobile/canvas-manipulation","description":"Helper functions for manipulating a HTMLCanvasElement","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@blinkmobile/canvas-manipulation","description":"Helper functions for manipulating a HTMLCanvasElement","version":"1.0.0","author":{"name":"Matt Carroll","email":"matt@blinkmobile.com.au","url":"https://github.com/mymattcarroll"},"bugs":{"url":"https://github.com/blinkmobile/canvas-manipulation/issues"},"devDependencies":{"babel-plugin-transform-es2015-modules-umd":"^6.22.0","del":"^2.2.2","eslint":"^3.15.0","eslint-config-standard":"^6.2.1","eslint-plugin-node":"^4.0.0","eslint-plugin-promise":"^3.4.1","eslint-plugin-standard":"^2.0.1","fixpack":"^2.3.1","flow-bin":"^0.38.0","gulp":"^3.9.1","jasmine":"^2.5.3","jasmine-core":"^2.5.2","karma":"^1.3.0","karma-chrome-launcher":"^2.0.0","karma-detect-browsers":"^2.2.4","karma-edge-launcher":"^0.2.0","karma-firefox-launcher":"^1.0.0","karma-ie-launcher":"^1.0.0","karma-jasmine":"^1.1.0","karma-opera-launcher":"^1.0.0","karma-phantomjs-launcher":"^1.0.2","karma-safari-launcher":"^1.0.0","opn-cli":"^3.1.0","remark-cli":"^2.1.0","remark-lint":"^5.4.0","remark-preset-lint-recommended":"^1.0.0","rollup":"^0.41.4","rollup-plugin-babel":"^2.7.1","rollup-plugin-uglify":"^1.0.1"},"directories":{"example":"example","test":"test"},"engines":{"node":">=6","npm":">=3"},"files":["dist"],"homepage":"https://github.com/blinkmobile/canvas-manipulation#readme","keywords":["HTML5","browser","canvas"],"license":"MIT","main":"dist/canvas-manipulation.js","publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/blinkmobile/canvas-manipulation.git"},"scripts":{"build":"gulp","eslint":"eslint --fix --cache .","fixpack":"fixpack","flow_check":"flow check","poststart":"npm run watch","posttest":"npm run eslint && npm run flow_check && npm run remark && npm run fixpack","pretest":"npm run build","remark":"remark . --preset lint-recommended","start":"opn ./example/index.html","test":"karma start","watch":"gulp watch"},"gitHead":"a1c58cd08185dee3661865dfc53ec500f65bf444","_id":"@blinkmobile/canvas-manipulation@1.0.0","_shasum":"0b9750c5249fb0035e2fe7549edf60836354f6c9","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.9.4","_npmUser":{"name":"blinkmobile","email":"ron@blinkmobile.com.au"},"dist":{"shasum":"0b9750c5249fb0035e2fe7549edf60836354f6c9","tarball":"https://registry.npmjs.org/@blinkmobile/canvas-manipulation/-/canvas-manipulation-1.0.0.tgz","integrity":"sha512-NjpNbZDTjmrPMcS7/ELq4HFdaGaofPTucBTaXYl2iH01owG0uxn0NPCD3PYGr1cS0KeIlwm2vgC0IXB0KwlmLg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHdWNYF/aVHsAN43wK8BP0b/kYJTaICUslogUiBpRKL/AiEAtgZKWao2Z+7PTFYnxuARIanmJa92BBN7D4IcEHkXr34="}]},"maintainers":[{"name":"blinkmobile","email":"ron@blinkmobile.com.au"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/canvas-manipulation-1.0.0.tgz_1486695047485_0.5633174309041351"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"1.0.1":{"name":"@blinkmobile/canvas-manipulation","description":"Helper functions for manipulating a HTMLCanvasElement","version":"1.0.1","author":{"name":"Matt Carroll","email":"matt@blinkmobile.com.au","url":"https://github.com/mymattcarroll"},"bugs":{"url":"https://github.com/blinkmobile/canvas-manipulation/issues"},"devDependencies":{"babel-plugin-transform-es2015-modules-umd":"^6.22.0","babel-preset-es2015":"^6.22.0","del":"^2.2.2","eslint":"^3.15.0","eslint-config-standard":"^6.2.1","eslint-plugin-node":"^4.0.0","eslint-plugin-promise":"^3.4.1","eslint-plugin-standard":"^2.0.1","fixpack":"^2.3.1","flow-bin":"^0.38.0","gulp":"^3.9.1","jasmine":"^2.5.3","jasmine-core":"^2.5.2","karma":"^1.3.0","karma-chrome-launcher":"^2.0.0","karma-detect-browsers":"^2.2.4","karma-edge-launcher":"^0.2.0","karma-firefox-launcher":"^1.0.0","karma-ie-launcher":"^1.0.0","karma-jasmine":"^1.1.0","karma-opera-launcher":"^1.0.0","karma-phantomjs-launcher":"^1.0.2","karma-safari-launcher":"^1.0.0","opn-cli":"^3.1.0","remark-cli":"^2.1.0","remark-lint":"^5.4.0","remark-preset-lint-recommended":"^1.0.0","rollup":"^0.41.4","rollup-plugin-babel":"^2.7.1","rollup-plugin-uglify":"^1.0.1"},"directories":{"example":"example","test":"test"},"engines":{"node":">=6","npm":">=3"},"files":["dist"],"homepage":"https://github.com/blinkmobile/canvas-manipulation#readme","keywords":["HTML5","browser","canvas"],"license":"MIT","main":"dist/canvas-manipulation.js","publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/blinkmobile/canvas-manipulation.git"},"scripts":{"build":"gulp","eslint":"eslint --fix --cache .","fixpack":"fixpack","flow_check":"flow check","poststart":"npm run watch","posttest":"npm run eslint && npm run flow_check && npm run remark && npm run fixpack","pretest":"npm run build","remark":"remark . --preset lint-recommended","start":"opn ./example/index.html","test":"karma start","watch":"gulp watch"},"gitHead":"90d4ff6fd8a93745ea86c7a6a5f835497dbb6033","_id":"@blinkmobile/canvas-manipulation@1.0.1","_shasum":"b8174986e68ff37d8d721f749b7f54a9db5fce03","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.9.4","_npmUser":{"name":"blinkmobile","email":"ron@blinkmobile.com.au"},"dist":{"shasum":"b8174986e68ff37d8d721f749b7f54a9db5fce03","tarball":"https://registry.npmjs.org/@blinkmobile/canvas-manipulation/-/canvas-manipulation-1.0.1.tgz","integrity":"sha512-SVeDtgzZbTcyrEn5H7SKYjkPwM9Mr60omrjEO8edfGtKv3eMgm6LAH2IqUuWXBjzSLofEJtzSP7A3/k/Vl4cKA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDPd1ObWYij/CvR2uzjj+ZG+eKnsJ9ryqUoVelq4EpEzAIhANsJLbfMpagTsXVzPV5h6iwhExl9GPbjrn/+fM8lgMoy"}]},"maintainers":[{"name":"blinkmobile","email":"ron@blinkmobile.com.au"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/canvas-manipulation-1.0.1.tgz_1486696386979_0.8691460869740695"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."}},"readme":"# blinkmobile / canvas-manipulation [![npm](https://img.shields.io/npm/v/@blinkmobile/canvas-manipulation.svg?maxAge=2592000)](https://www.npmjs.com/package/@blinkmobile/canvas-manipulation) [![AppVeyor Status](https://img.shields.io/appveyor/ci/blinkmobile/canvas-manipulation/master.svg)](https://ci.appveyor.com/project/blinkmobile/canvas-manipulation) [![Travis CI Status](https://travis-ci.org/blinkmobile/canvas-manipulation.svg?branch=master)](https://travis-ci.org/blinkmobile/canvas-manipulation)\n\nHelper functions for manipulating a HTMLCanvasElement\n\n## Installation\n\n1.  Install module via npm\n\n    ```\n    npm install @blinkmobile/canvas-manipulation --save\n    ```\n\n1.  Load this library and use a build step e.g. [webpack](https://webpack.github.io/) or [browserify](http://browserify.org/)\n\n    ```js\n    const canvasManipulation = require('@blinkmobile/canvas-manipulation')\n    // OR\n    import canvasManipulation from '@blinkmobile/canvas-manipulation'\n    ```\n\n1.  Or alternatively, load the script straight into a browser and access `canvasManipulation` globally\n\n    ```html\n    <!DOCTYPE html>\n    <html>\n    <head>\n      <script src=\"node_modules/@blinkmobile/canvas-manipulation/dist/canvas-manipulation.js\"></script>\n    </head>\n    <body>\n      ...\n      <script>\n        // available via window.canvasManipulation\n      </script>\n    </body>\n    </html>\n    ```\n\n## Usage\n\n##### `drawImageCentered(canvas: HTMLCanvasElement, image: CanvasImageSource)`\n\n-   Draw a [CanvasImageSource](https://developer.mozilla.org/en-US/docs/Web/API/CanvasImageSource) onto a [HTMLCanvasElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement)\n\n-   Will center the image onto the canvas if the image is smaller than the canvas\n\n-   Will scale the image down to fit if the image is bigger than the canvas\n\n##### `resize(canvas: HTMLCanvasElement, width: number, height: number, scaleDown: boolean) : boolean`\n\n-   Change the width and/or height of a [CanvasImageSource](https://developer.mozilla.org/en-US/docs/Web/API/CanvasImageSource) while preserving the current content\n\n-   Returns `true` if the canvas content has been preserved\n\n-   If `scaleDown` is `false` and the content is larger than the newly sized canvas, the content will **not** be preserved\n\n##### `toDataURLCropped(canvas: HTMLCanvasElement, type: string, encoderOptions: number) : string`\n\n-   Create a [DataURL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) after cropping canvas content of white (transparent, the alpha must be 0) space\n\n-   `type` and `encoderOptions` arguments are optional, see [HTMLCanvasElement.toDataURL() Parameters](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL#Parameters) for options and defaults\n\n-   Returns a [DataURL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs)\n\n## Example\n\nCheck the `example` directory for a working example or run it yourself:\n\n1.  Install [Node 6.x](https://nodejs.org/en/download/) or higher\n\n1.  Clone this repository\n\n    **Note**: The master branch can contain undocumented or backward compatibility breaking changes. You should checkout the latest release before running the demo.\n\n1.  Install dependencies\n\n    ```\n    npm install\n    ```\n\n1.  Start demo\n\n    ```\n    npm start\n    ```\n","maintainers":[{"email":"aaronroworth@gmail.com","name":"aaronroworth"},{"email":"ron@blinkmobile.com.au","name":"blinkmobile-admin"},{"email":"kizaonline@gmail.com","name":"kizaonline"},{"email":"matt.carroll139@gmail.com","name":"mymattcarroll"},{"email":"simondobie23@gmail.com","name":"simon_marklar"}],"time":{"modified":"2023-08-23T01:47:40.398Z","created":"2017-02-10T02:50:47.733Z","1.0.0":"2017-02-10T02:50:47.733Z","1.0.1":"2017-02-10T03:13:08.602Z"},"homepage":"https://github.com/blinkmobile/canvas-manipulation#readme","keywords":["HTML5","browser","canvas"],"repository":{"type":"git","url":"git+https://github.com/blinkmobile/canvas-manipulation.git"},"author":{"name":"Matt Carroll","email":"matt@blinkmobile.com.au","url":"https://github.com/mymattcarroll"},"bugs":{"url":"https://github.com/blinkmobile/canvas-manipulation/issues"},"license":"MIT","readmeFilename":"README.md"}