Skip to content

Commit 6dda547

Browse files
committed
(#3) Exposed highlight function via libnut
1 parent ae23f2f commit 6dda547

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ function bitmap(width, height, byteWidth, bitsPerPixel, bytesPerPixel, image) {
1717
};
1818
}
1919

20+
module.exports.screen.highlight = libnut.highlight;
21+
2022
module.exports.screen.capture = function(x, y, width, height) {
2123
//If coords have been passed, use them.
2224
if (

src/libnut.cc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "MMBitmap.h"
1212
#include "snprintf.h"
1313
#include "microsleep.h"
14+
#include "window.h"
1415
#if defined(USE_X11)
1516
#include "xdisplay.h"
1617
#endif
@@ -710,6 +711,31 @@ Napi::Number _setXDisplayName(const Napi::CallbackInfo &info)
710711
#endif
711712
}
712713

714+
Napi::Number _highlight(const Napi::CallbackInfo &info)
715+
{
716+
Napi::Env env = info.Env();
717+
int x;
718+
int y;
719+
int width;
720+
int height;
721+
int duration;
722+
float opacity;
723+
724+
if (info.Length() == 6)
725+
{
726+
x = info[0].As<Napi::Number>().Int32Value();
727+
y = info[1].As<Napi::Number>().Int32Value();
728+
width = info[2].As<Napi::Number>().Int32Value();
729+
height = info[3].As<Napi::Number>().Int32Value();
730+
duration = info[4].As<Napi::Number>().Int32Value();
731+
opacity = info[5].As<Napi::Number>().FloatValue();
732+
733+
highlight(x, y, width, height, duration, opacity);
734+
return Napi::Number::New(env, 1);
735+
}
736+
return Napi::Number::New(env, 1);
737+
}
738+
713739
Napi::Object _captureScreen(const Napi::CallbackInfo &info)
714740
{
715741
Napi::Env env = info.Env();
@@ -873,6 +899,7 @@ Napi::Object Init(Napi::Env env, Napi::Object exports)
873899

874900
exports.Set(Napi::String::New(env, "getPixelColor"), Napi::Function::New(env, _getPixelColor));
875901
exports.Set(Napi::String::New(env, "getScreenSize"), Napi::Function::New(env, _getScreenSize));
902+
exports.Set(Napi::String::New(env, "highlight"), Napi::Function::New(env, _highlight));
876903
exports.Set(Napi::String::New(env, "captureScreen"), Napi::Function::New(env, _captureScreen));
877904
exports.Set(Napi::String::New(env, "getColor"), Napi::Function::New(env, _getColor));
878905
exports.Set(Napi::String::New(env, "getXDisplayName"), Napi::Function::New(env, _getXDisplayName));

0 commit comments

Comments
 (0)