source: imaps-frontend/node_modules/stackblur-canvas/README.md

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 4.2 KB
Line 
1# StackBlur.js
2
3[![NPM Version](https://img.shields.io/npm/v/stackblur-canvas.svg)][pkg-npm]
4[![License](https://img.shields.io/npm/l/stackblur-canvas.svg)](https://github.com/flozz/StackBlur/blob/master/COPYING)
5
6StackBlur.js is a fast, almost Gaussian blur created by Mario Klingemann.
7
8 * **More informations:** <http://incubator.quasimondo.com/processing/fast_blur_deluxe.php>
9 * **Algorithm:** <https://medium.com/better-programming/blurring-image-algorithm-example-in-android-cec81911cd5e>
10 * **Demo:** <http://www.quasimondo.com/StackBlurForCanvas/StackBlurDemo.html>
11
12Original source:
13
14 * <http://www.quasimondo.com/StackBlurForCanvas/StackBlur.js>
15
16## Getting Started
17
18### Standalone version
19
20To use the standalone version,
21
22download the [latest zip][dl-zip-master] from Github or clone the repository
23
24```
25git clone git@github.com:flozz/StackBlur.git
26```
27
28and include the `dist/stackblur.js` or `dist/stackblur.min.js` file in your HTML page:
29
30```html
31<script src="StackBlur/dist/stackblur.js"></script>
32```
33
34### Node
35
36To use the [NPM package][pkg-npm],
37
38install the package:
39
40```
41npm install --save stackblur-canvas
42```
43
44and require it where needed
45
46```js
47const StackBlur = require('stackblur-canvas');
48```
49
50### Browsers
51
52If you are only supporting modern browsers, you may use ES6 Modules directly:
53
54```js
55import * as StackBlur from
56 './node_modules/stackblur-canvas/dist/stackblur-es.min.js';
57```
58
59Or, if you are using Rollup in your own project, use the [node-resolve](https://github.com/rollup/rollup-plugin-node-resolve) plugin,
60and import by just referencing the module:
61
62```js
63import * as StackBlur from 'stackblur-canvas';
64```
65
66## API
67
68See also the docs in [docs/jsdoc](./docs/jsdoc/index.html).
69
70**Image as source:**
71
72```js
73StackBlur.image(sourceImage, targetCanvas, radius, blurAlphaChannel);
74```
75
76 * `sourceImage`: the `HTMLImageElement` or its `id`.
77 * `targetCanvas`: the `HTMLCanvasElement` or its `id`.
78 * `radius`: the radius of the blur.
79 * `blurAlphaChannel`: Set it to `true` if you want to blur a RGBA image (optional, default = `false`)
80
81**RGBA Canvas as source:**
82
83```js
84StackBlur.canvasRGBA(targetCanvas, top_x, top_y, width, height, radius);
85```
86
87 * `targetCanvas`: the `HTMLCanvasElement`.
88 * `top_x`: the horizontal coordinate of the top-left corner of the rectangle to blur.
89 * `top_y`: the vertical coordinate of the top-left corner of the rectangle to blur.
90 * `width`: the width of the rectangle to blur.
91 * `height`: the height of the rectangle to blur.
92 * `radius`: the radius of the blur.
93
94**RGB Canvas as source:**
95
96```js
97StackBlur.canvasRGB(targetCanvas, top_x, top_y, width, height, radius);
98```
99
100 * `targetCanvas`: the `HTMLCanvasElement`.
101 * `top_x`: the horizontal coordinate of the top-left corner of the rectangle to blur.
102 * `top_y`: the vertical coordinate of the top-left corner of the rectangle to blur.
103 * `width`: the width of the rectangle to blur.
104 * `height`: the height of the rectangle to blur.
105 * `radius`: the radius of the blur.
106
107**RGBA ImageData as source:**
108
109```js
110StackBlur.imageDataRGBA(imageData, top_x, top_y, width, height, radius);
111```
112
113 * `imageData`: the canvas' `ImageData`.
114 * `top_x`: the horizontal coordinate of the top-left corner of the rectangle to blur.
115 * `top_y`: the vertical coordinate of the top-left corner of the rectangle to blur.
116 * `width`: the width of the rectangle to blur.
117 * `height`: the height of the rectangle to blur.
118 * `radius`: the radius of the blur.
119
120**RGB ImageData as source:**
121
122```js
123StackBlur.imageDataRGB(imageData, top_x, top_y, width, height, radius);
124```
125
126 * `imageData`: the canvas' `ImageData`.
127 * `top_x`: the horizontal coordinate of the top-left corner of the rectangle to blur.
128 * `top_y`: the vertical coordinate of the top-left corner of the rectangle to blur.
129 * `width`: the width of the rectangle to blur.
130 * `height`: the height of the rectangle to blur.
131 * `radius`: the radius of the blur.
132
133
134## Hacking
135
136### Building
137
138This library is built using [Rollup](https://rollupjs.org/guide/en).
139If you change something in the `src/` folder, use the following command
140to re-build the files in the `dist/` folder:
141
142`npm run rollup`
143
144
145[dl-zip-master]: https://github.com/flozz/StackBlur/archive/master.zip
146[pkg-npm]: https://www.npmjs.com/package/stackblur-canvas
147[grunt]: http://gruntjs.com/
Note: See TracBrowser for help on using the repository browser.