Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): round rects when applying transform
Due to the limited floating point precision, and konva's `scale` properties, it is possible for the relative rect of an object to have non-integer coordinates and dimensions. When we go to rasterize and otherwise export images, the HTML canvas API truncates these numbers. So, we can end up with situations where the relative width and height of a layer are very close to the "real" value, but slightly off. For example, width and height might be 512px, but the relative rect is calculated to be something like 512.000000003 or 511.9999999997. In the first case, the truncation results in 512x512 for the dimensions - which is correct. But in the second case, it results in 511x511! One place where this causes issues is the image action `New Canvas from image -> As Raster Layer (resize)`. For certain input image sizes, this results in an incorrectly resized image. For example, a 1496x1946 input image is resized to 511x511 pixels when the bbox is 512x512. To fix this, we can round both coords and dimensions of rects when rasterizing. I've thought through the implications and done some testing. I believe this change will not cause any regressions and only fix edge cases. But, it's possible that something was inadvertently relying on the old behavior.
- Loading branch information