You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to use HTML Canvas outside of JavaScript. Is it possible to use the node-canvas library directly from C++ instead of using it from JavaScript? Going through the code it looks like NAPI code is fairly ingrained into the C++ code and not just a surface layer binding.
Being able to use HTML Canvas from native code instead of having to directly use Cairo which is much more low level would make my life much easier.
The text was updated successfully, but these errors were encountered:
I wouldn't call Cairo lower-level than JS canvas. Other than the fact that Cairo uses C data structures and calling conventions, it's pretty much the same API. I definitely wouldn't try to call NAPI/JS from C++ if you're already in native code.
Because I can't use node-canvas outside of JavaScript, I've been working on porting node-canvas from C++ to Dart and I've found an odd bug.
If I call ctx.roundRect(x, y, w, h, [r, r, r, r]) the expected output is that all radiuses are rounded, but only the upper left radius is rounded as is seen in the left half of the attached screenshot.
I looked into the implementation for Context2d::RoundRect and find
auto top = upperLeft.x + upperRight.x;
auto right = upperRight.y + lowerRight.y;
auto bottom = lowerRight.x + lowerLeft.x;
auto left = upperLeft.y + lowerLeft.y;
auto scale = std::min({ width / top, height / right, width / bottom, height / left });
if (scale < 1.) {
upperLeft.x *= scale;
upperLeft.y *= scale;
upperRight.x *= scale;
upperRight.x *= scale;
lowerLeft.y *= scale;
lowerLeft.y *= scale;
lowerRight.y *= scale;
lowerRight.y *= scale;
}
Is it intended for both the x and y of the upper left corner to be scaled, but only the x component of upperRight and only the y component of lowerLeft and lowerRight to be scaled? I can't imagine why that would be the intended behavior.
I tried scaling both the x and y component of all corners like so
I want to use HTML Canvas outside of JavaScript. Is it possible to use the node-canvas library directly from C++ instead of using it from JavaScript? Going through the code it looks like NAPI code is fairly ingrained into the C++ code and not just a surface layer binding.
Being able to use HTML Canvas from native code instead of having to directly use Cairo which is much more low level would make my life much easier.
The text was updated successfully, but these errors were encountered: