Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transforms completely broken in all versions >= 0.1.29 #629

Closed
controversial opened this issue Feb 9, 2023 · 1 comment · Fixed by #633
Closed

Transforms completely broken in all versions >= 0.1.29 #629

controversial opened this issue Feb 9, 2023 · 1 comment · Fixed by #633
Assignees
Labels
bug Something isn't working

Comments

@controversial
Copy link

The functionality of ctx.setTransform is completely broken starting in @napi-rs/canvas 0.1.29.

real-world example: broken visualization

A user-facing visualization I maintain for work is generated using @napi-rs/canvas. We’re stuck on version 0.1.28, because of the broken transform functionality. Using identical canvas code, we have the following results (note the text rendering differences in the Chrome example are irrelevant).

@napi-rs/canvas 0.1.28 @napi-rs/canvas >= 0.1.29 Chrome 109

Here’s a minimal example which shows the problem:

import { DOMMatrix, createCanvas } from '@napi-rs/canvas';
const canvas = createCanvas(400, 400);
/* or, in chrome:
const canvas = document.createElement('canvas');
canvas.width = 400;
canvas.height = 400;
document.body.appendChild(canvas);
*/


const ctx = canvas.getContext('2d');
const mat = new DOMMatrix()
  .rotate(30)
  .skewX(30)
  .scale(1, Math.sqrt(3) / 2);
ctx.setTransform(mat);
ctx.fillStyle = 'red';
ctx.fillRect(100, 100, 100, 100);


const buffer = await canvas.encode('png');
@napi-rs/canvas 0.1.28 @napi-rs/canvas >= 0.1.29 Chrome 109

Note that DOMMatrix generates the same matrix across all three platforms; it’s the rendering after applying that transform which is broken.

@controversial
Copy link
Author

Thanks for fixing this so quickly @Brooooooklyn! Do you plan to cut/publish a new release soon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants