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
Describe the bug
Same transform behaves differently depending on if it is set with individual values or as a matrix.
To Reproduce
//1let t = ggez::graphics::Transform::Values{dest:Point2{x:100.0,y:100.0},rotation:0.0,scale:Vector2{x:10.0,y:10.0},offset:Point2{x:0.5,y:0.5}};
canvas.draw(&image,DrawParam::new().src(src).transform(t.to_bare_matrix()));//2let param = DrawParam::new().src(src).dest([100.0,100.0]).rotation(0.0).scale([10.0,10.0]).offset([0.5,0.5]);
canvas.draw(&image, param);
Expected behavior
These two draw commands should draw the same thing because they are identical but they don't. When using the matrix form, the offset doesn't center the image. In order to get the same result, I have to set offset to (image.width/2, image.height/2).
This is because image scaling (where the transform is scaled up by the image size) is applied after the offset calculation (which is based on scale). Basically to bring this up to equivalence without API changes you could disable image scaling in the DrawParam and manually scale the scale values by the image size.
In the API though it would probably be helpful if we exposed a parameter in to_bare_matrix that accepted an image scale parameter so that it's easier to emulate the same behaviour using Transform::Values.
Describe the bug
Same transform behaves differently depending on if it is set with individual values or as a matrix.
To Reproduce
Expected behavior
These two draw commands should draw the same thing because they are identical but they don't. When using the matrix form, the offset doesn't center the image. In order to get the same result, I have to set offset to (image.width/2, image.height/2).
I believe the issue is here in /graphics/draw.rs:
These 2 arms of the match don't produce the same result.
Screenshots or pasted code
Hardware and Software:
The text was updated successfully, but these errors were encountered: