-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathindex.js
41 lines (35 loc) · 920 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const libnut = require("bindings")("libnut.node");
module.exports = libnut;
module.exports.screen = {};
function bitmap(width, height, byteWidth, bitsPerPixel, bytesPerPixel, image) {
this.width = width;
this.height = height;
this.byteWidth = byteWidth;
this.bitsPerPixel = bitsPerPixel;
this.bytesPerPixel = bytesPerPixel;
this.image = image;
this.colorAt = function(x, y) {
return libnut.getColor(this, x, y);
};
}
module.exports.screen.capture = function(x, y, width, height) {
//If coords have been passed, use them.
if (
typeof x !== "undefined" &&
typeof y !== "undefined" &&
typeof width !== "undefined" &&
typeof height !== "undefined"
) {
b = libnut.captureScreen(x, y, width, height);
} else {
b = libnut.captureScreen();
}
return new bitmap(
b.width,
b.height,
b.byteWidth,
b.bitsPerPixel,
b.bytesPerPixel,
b.image
);
};