Select two misaligned groups, align top - groups align but move half a pixel in the x-axis, ignoring the pixel fitting setting and requiring me to manually edit the x position of each group. Bug or feature?
Env: MacBook Pro, Ventura 13.5, Sketch 97.2 (173315)
Settings / Layers /
Hi Mathieu, welcome to the Forum! I just tested with two groups of shapes and two groups of text layers, aligning to top and also relative to the artboard. In both cases the X position was consistent after aligning the groups. Could it be that the group was on a half pixel position before aligning?
Also, it’s worth running Sketch in Safe Mode, just in case: quit the Mac app and then launch it again while holding down the Shift key ⇧ . This opens it in Safe Mode and if everything works as expected, a plugin may have been causing the issue.
Hola Jorge. Que tal?
I have no plugins installed
Groups of layers are on whole pixels to begin with.
Groups are composed of rectangles, not strokes
After align top…
Hola Mathieu! Todo bien
I found why this happens. It has to do with rotation and dimensions. Let’s go into details about dimension.
In the example you provided, if the shape is has an even width number, say, 30 like in the image you shared, and you rotate it, it will end up in half pixels, which you may not notice and after aligning, it will align to a half pixel.
If you then get rid of the 0.5px and realign, it will fall again in half pixels, due to the shape’s height (after being rotated). You’d need to make the shape’s height an odd number for it to align to a full pixel, which may not be viable if you need a specific height.
If the shape has an odd width number, say 31, and you rotate and then align to top, it will align on full pixels.
Another workaround is to create new layers instead of rotating them. If you create the shape on the right with new rectangles and avoid rotation, it will align on full pixels on odd or even values
I’ll reach out internally with the team to see what’s going on and provide an update you as soon as I have some news.
Here’s a sample file for you to test with. I hope this helps
Rotated shapes.sketch (269.4 KB)
I’ve been on holiday for a while.
Thanks for your response.
Why does an object sitting on full pixels with an even numbered height get placed on half pixels when rotated, in spite of the sketch preference being set to use full pixels?
This happens because rotation is done from the center of the shape, so if you have a 2x1 rectangle sitting on 0,0 and rotate 90°, it will land on 0.5
And that’s why even number widths don’t have this behavior.
Of course, I can clearly see the expectation is that the Pixel fitting option is to also affect these rotation edits. I’ve documented this case and shared it with the team.