dmester / canvas-renderer Goto Github PK
View Code? Open in Web Editor NEWHTML5 inspired canvas implemented in Node.js for rendering PNG images.
License: MIT License
HTML5 inspired canvas implemented in Node.js for rendering PNG images.
License: MIT License
The following exception is thrown:
RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= 0 and <= 4294967295. Received -1109855489
at checkInt (internal/buffer.js:35:11)
at writeU_Int32BE (internal/buffer.js:623:3)
at Buffer.writeUInt32BE (internal/buffer.js:636:10)
at PngEncoder_writeTrueColorWithAlpha [as writeTrueColorWithAlpha] (F:\CanvasRenderer\lib\png\pngEncoder.js:79:24)
at Canvas_toPng [as toPng] (F:\CanvasRenderer\lib\canvas.js:113:13)
at Canvas_toDataURL [as toDataURL] (F:\CanvasRenderer\lib\canvas.js:131:20)
at Object.<anonymous> (F:\CanvasRenderer\tests\trueColorTest.js:67:58)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:282:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
The exception is only thrown for images that contain more than 256 colors, where at least one color has a red channel value over 127.
This was reported in dmester/jdenticon#33.
When the reulting image contains more than 256 colors, it can no longer be represented as a PNG with a palette, but is instead saved as a true-color PNG. Node function Buffer.writeUInt32BE
is used to write the color data to the PNG data stream. This function had a parameter called noAssert
which essentially forced the value to an unsigned 32 bit integer, even when the value was a negative number.
In Node 10.x and later, noAssert
has been removed, and the function will now instead throw an exception when a negative number is passed to the function. This was sometimes done by canvas-renderer when the red component of the color was larger than 127, since canvas-renderer handled both unsigned and signed integers as color values.
Convert all color functions to return signed integers as color values. Signed integers are prefered over unsigned integers since all bitwise operators in JS convert all operands to signed 32-bit integers.
Also replace Buffer.writeUInt32BE
with Buffer.writeInt32BE
.
please implement toDataURL method
https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.