Answer the question
In order to leave comments, you need to log in
How to modify a package?
I have a "node-images" package and I need to add a function to it that draws a black pixel at the given coordinates. I manually downloaded this package from GitHub and modified the following files:
index.js - added the lines
71. drawDot: function(x, y) {
72. this._handle.dot(x, y);
72. },
207.
208. static void DrawDot(const v8::FunctionCallbackInfo<v8::Value> &args);
106. NODE_SET_PROTOTYPE_METHOD(tpl, "dot", DrawDot);
...
422.
423. void Image::DrawDot(const FunctionCallbackInfo<Value> &args) { // {{{
424.
425. Image *dst;
426. uint32_t x, y;
427. Pixel *cp;
428.
429. dst = node::ObjectWrap::Unwrap<Image>(args.This());
430.
431. x = args[0]->Uint32Value();
432. y = args[1]->Uint32Value();
433.
434. cp = &color;
435. cp->R = 0;
436. cp->G = 0;
437. cp->B = 0;
438. cp->A = 0xFF;
439.
440. dst->pixels->data[x][y] = cp;
441.
442. args.GetReturnValue().Set(v8::Undefined(args.GetIsolate()));
443. } // }}}
const images = require("images");
images(300, 300).drawDot(10,10);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question