{"_id":"@crazytoucan/pngjs-draw","_rev":"3-91d5e464ae4d6df6202564c301876f59","name":"@crazytoucan/pngjs-draw","description":"Adds basic drawing functionnalities to pngjs.","dist-tags":{"latest":"0.0.7"},"versions":{"0.0.7":{"name":"@crazytoucan/pngjs-draw","version":"0.0.7","description":"Adds basic drawing functionnalities to pngjs.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/aloisdeniel/node-pngjs-draw.git"},"keywords":["pngjs","draw","shapes","strings","text","line","rectangle","png"],"author":{"name":"Aloïs Deniel"},"license":"MIT","bugs":{"url":"https://github.com/aloisdeniel/node-pngjs-draw/issues"},"homepage":"https://github.com/aloisdeniel/node-pngjs-draw","dependencies":{"pngjs":"^0.4.0"},"gitHead":"dc848af045a49563ec45669c95a0e298c980ff0a","_id":"@crazytoucan/pngjs-draw@0.0.7","_shasum":"004c70f42f226fdeb5e5feba854c18501e1cfb28","_from":".","_npmVersion":"3.5.3","_nodeVersion":"0.12.4","_npmUser":{"name":"crazytoucan","email":"crazytoucan0@gmail.com"},"dist":{"shasum":"004c70f42f226fdeb5e5feba854c18501e1cfb28","tarball":"https://registry.npmjs.org/@crazytoucan/pngjs-draw/-/pngjs-draw-0.0.7.tgz","integrity":"sha512-zjF+GQP6BEDrfTQCXLRNagKV45uFQwXUHg/PJXfmLCB5CPdPKCET5diQPmD0GXBaOYoz+0SRt7hTKOZJr4T+gw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEb2+ATIYEQ1g8y+XZACkeyvgOFtgdpe7SJ7c/Rkw/m/AiAjZ6aTw6HGNb2ZKCMkrn3GbP22dydgSpeQY/nhzqRqNA=="}]},"maintainers":[{"name":"crazytoucan","email":"crazytoucan0@gmail.com"}]}},"readme":"# node-pngjs-draw\n\nAdds basic drawing functionnalities to [pngjs](https://github.com/niegowski/node-pngjs) node module.\n\n## Install\n\n```sh\n$ npm install --save pngjs-draw\n```\n\n## Example\n\n```js\nvar fs = require('fs');\nvar drawing = require('pngjs-draw');\nvar png = drawing(require('pngjs').PNG);\n\nfs.createReadStream(\"blue.png\")\n  .pipe(new png({ filterType: 4 }))\n  .on('parsed', function() {\n    // Draws a pixel with transparent green\n    this.drawPixel(150,200, this.colors.black())\n\n    // Draws a line with transparent red\n    this.drawLine(0,0,200,200, this.colors.red(50))\n\n    // Draws a rectangle with transparent black\n    this.fillRect(150,150,75,20, this.colors.black(100))\n\n    // Draws a filled rectangle with transparent white\n    this.fillRect(50,50,100,100, this.colors.white(100))\n\n    // Draws a text with custom color\n    this.drawText(20,20, \"Hello world !\", this.colors.new(255,100,10))\n\n    // Writes file\n    this.pack().pipe(fs.createWriteStream('blue.out.png'));\n  });\n```\n\n## Documentation\n\n### PNG.prototype.drawPixel\n\nDraws the pixel at the given coordinates with the given color.\n\n* {`int`} `x` The x coordinate of the pixel\n* {`int`} `y` The y coordinate of the pixel\n* {`Array(byte)`} `color` The color used to paint the pixel\n\n### PNG.prototype.drawLine\n\nDraws a line beetween two points with the given color.\n\n* {`int`} `x0` The x coordinate of the start\n* {`int`} `y0` The y coordinate of the start\n* {`int`} `x1` The x coordinate of the end\n* {`int`} `y1` The y coordinate of the end\n* {`Array(byte)`} `color` The color used to paint the line\n\n### PNG.prototype.drawRect\n\nDraws a stroked rectangle with the given color.\n\n* {`int`} `x` The top left x coordinate of the rectangle\n* {`int`} `y` The top left y coordinate of the rectangle\n* {`int`} `width` The width of the rectangle\n* {`int`} `height` The height of the rectangle\n* {`Array(byte)`} `color` The color used to  paint strokes of the rectangle\n\n### PNG.prototype.fillRect\n\nDraws a filled rectangle with the given color.\n\n* {`int`} `x` The top left x coordinate of the rectangle\n* {`int`} `y` The top left y coordinate of the rectangle\n* {`int`} `width` The width of the rectangle\n* {`int`} `height` The height of the rectangle\n* {`Array(byte)`} `color` The color used to fill the rectangle\n\n### PNG.prototype.drawText\n\nDraw a text to the image.\n\n* {`int`} `x` The top left x coordinate of the string\n* {`int`} `y` The top left y coordinate of the string\n* {`string`} `text` The string value\n* {`Array(byte)`} `color` The color used used as foreground\n* {`Object`} `font` The font used to render the string (optional)\n* {`Object`} `text` The string value\n\n**return** {`int`} The length in pixel of the rendered string\n\n### PNG.prototype.measureString\n\nMeasure the rendered text length with the given font.\n\n* {`string`} `text` The string value\n* {`Array(byte)`} `color` The color used used as foreground\n* {`Object`} `font` The font used to render the string (optional)\n\n**return** {`int`} The length in pixel of the rendered string\n\n### Creating colors\n\n`[<R>,<G>,<B>,<A>]`\n\nA color is a javascript array containing Red/Green/Blue/Alpha byte components.\n\n`PNG.prototype.colors.new = function(r,g,b,a)`\n\nThe new method generates an array with the provided components.\n\nDefault values :\n\n* r: `0`\n* g: `0`\n* b: `0`\n* a: `255`\n\n```\nPNG.prototype.colors.red = function(a)\nPNG.prototype.colors.greed = function(a)\nPNG.prototype.colors.blue = function(a)\nPNG.prototype.colors.black = function(a)\nPNG.prototype.colors.white = function(a)\n```\n\nHelper methods for creating base colors are also available.\n\n### Custom fonts\n\nIn order to use a custom font, you must first generate a font module from an image presenting all the supported characters.\n\nFor more details, take a look at these files :\n* `build-font.js`\n* `fonts/*`\n* `custom-font/*`\n\n## Roadmap / Ideas\n\n* More shapes (circles, polygons)\n* Rotations\n* Multi-lines texts\n\n## Copyright and license\n\nMIT © [Aloïs Deniel](http://aloisdeniel.github.io)\n","maintainers":[{"name":"crazytoucan","email":"crazytoucan0@gmail.com"}],"time":{"modified":"2022-06-12T16:45:26.460Z","created":"2016-01-31T04:54:43.148Z","0.0.7":"2016-01-31T04:54:43.148Z"},"homepage":"https://github.com/aloisdeniel/node-pngjs-draw","keywords":["pngjs","draw","shapes","strings","text","line","rectangle","png"],"repository":{"type":"git","url":"git+https://github.com/aloisdeniel/node-pngjs-draw.git"},"author":{"name":"Aloïs Deniel"},"bugs":{"url":"https://github.com/aloisdeniel/node-pngjs-draw/issues"},"license":"MIT","readmeFilename":"README.md"}