Skip to content

Commit 8e4ab12

Browse files
committed
added npm support
1 parent 4c45fa8 commit 8e4ab12

File tree

3 files changed

+58
-26
lines changed

3 files changed

+58
-26
lines changed

package.json

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,61 @@
11
{
2-
"main": "HTMLCanvasElement.js",
2+
"name": "canvas-webworker",
3+
"description": "Pure JavaScript Canvas implimentation that can be used in WebWorkers",
4+
"version": "0.0.1",
5+
"main": "lib/index.js",
6+
"files": [
7+
"lib"
8+
],
39
"directories": {
4-
"lib": "src"
10+
"lib": "src",
11+
"example": "example"
12+
},
13+
"format": "esm",
14+
"dependencies": {
15+
"clipper-js": "0.0.2",
16+
"get-pixels": "^3.3.0"
17+
},
18+
"devDependencies": {
19+
"babel-cli": "^6.6.5",
20+
"babel-core": "^6.7.2",
21+
"babel-preset-es2015": "^6.6.0",
22+
"babel-preset-stage-0": "^6.5.0",
23+
"jspm": "^0.16.31"
24+
},
25+
"scripts": {
26+
"prepublish": "npm run build",
27+
"build": "node_modules/babel-cli/bin/babel.js src --out-dir lib",
28+
"test": "echo \"Error: no test specified\" && exit 1"
29+
},
30+
"author": "Casper Lamboo",
31+
"license": "MIT",
32+
"homepage": "https://github.com/casperlamboo/canvas-webworker#readme",
33+
"repository": {
34+
"type": "git",
35+
"url": "git+https://github.com/casperlamboo/canvas-webworker.git"
36+
},
37+
"bugs": {
38+
"url": "https://github.com/casperlamboo/canvas-webworker/issues"
39+
},
40+
"keywords": [
41+
"canvas",
42+
"webworkers",
43+
"canvasrenderingcontext2d",
44+
"drawing",
45+
"2d",
46+
"context"
47+
],
48+
"babel": {
49+
"presets": [
50+
"es2015",
51+
"stage-0"
52+
]
553
},
654
"jspm": {
55+
"main": "index.js",
56+
"directories": {
57+
"lib": "src"
58+
},
759
"dependencies": {
860
"clipper-js": "github:Doodle3D/clipper-js@^0.0.2",
961
"get-pixels": "npm:get-pixels@^3.3.0"

src/ImageData.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,10 @@
1-
let context;
2-
3-
if (document !== undefined) {
4-
const canvas = document.createElement('canvas');
5-
context = canvas.getContext('2d');
6-
}
7-
81
export default class ImageData {
92
constructor(width, height, data = Uint8ClampedArray(width * height * 4)) {
103
this._data = data;
114
this._width = width;
125
this._height = height;
136
}
147

15-
toReal() {
16-
if (context !== undefined) {
17-
const imageData = context.createImageData(this.width, this.height);
18-
const data = this.data;
19-
20-
for (let i = 0; i < data.length; i ++) {
21-
imageData.data[i] = data[i];
22-
}
23-
24-
return imageData;
25-
}
26-
27-
return null;
28-
}
29-
308
get data() { return this._data; }
319
get width() { return this._width; }
3210
get height() { return this._height; }

src/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
import HTMLcanvasElement from './HTMLCanvasElement.js';
1+
import HTMLCanvasElement from './HTMLCanvasElement.js';
2+
import image from './Image.js';
23

3-
export default HTMLcanvasElement;
4+
export const Canvas = HTMLCanvasElement;
5+
export const Image = image;

0 commit comments

Comments
 (0)