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
The jest-canvas-mock/CanvasRenderingContext2D class save and restore operations should behave in the same way as browser/CanvasRenderingContext2D but it doesn't.
If we execute the following code:
function_do(cont){vartmp=[];cont.scale(0.5,0.5);cont.save();tmp.push(cont.getTransform().m11);cont.scale(0.5,0.5);tmp.push(cont.getTransform().m11);cont.restore();tmp.push(cont.getTransform().m11);console.log(tmp);}varthe_canvas=somerealcanvas;console.log("save/restore sequence for browser/CanvasRenderingContext2D")_do(the_canvas.getContext('2d'));console.log("save/restore sequence for jest-canvas-mock/CanvasRenderingContext2D")_do(newCanvasRenderingContext2D(the_canvas));
We get the following output:
save/restore sequence for browser/CanvasRenderingContext2D
Array(3) [ 0.5, 0.25, 0.5 ]
save/restore sequence for jest-canvas-mock/CanvasRenderingContext2D
Array(3) [ 0.5, 0.25, 0.25 ]
Expected behaviour
The output for jest-canvas-mock/CanvasRenderingContext2D should be the same as browser/CanvasRenderingContext2D...
Array(3) [ 0.5, 0.25, 0.5 ]
... instead of...
Array(3) [ 0.5, 0.25, 0.25 ]
(notice the 0.25 intead of 0.5 as last element in the array)
The text was updated successfully, but these errors were encountered:
tmarti
changed the title
Problem with context.save () and context.restore ()
[with solution]: Problem with context.save () and context.restore ()
Oct 31, 2019
The problem
The
jest-canvas-mock/CanvasRenderingContext2D
classsave
andrestore
operations should behave in the same way asbrowser/CanvasRenderingContext2D
but it doesn't.If we execute the following code:
We get the following output:
Expected behaviour
The output for
jest-canvas-mock/CanvasRenderingContext2D
should be the same asbrowser/CanvasRenderingContext2D
...... instead of...
(notice the
0.25
intead of0.5
as last element in the array)The text was updated successfully, but these errors were encountered: