lbalazscs / Pixelitor

A desktop image editor
https://pixelitor.sourceforge.io/
GNU General Public License v3.0
182 stars 71 forks source link

[Feature Request] Add an option to selection tool to snap to pixels #307

Closed Imerion closed 1 year ago

Imerion commented 1 year ago

When I work with small details, especially for pixel art, it would be useful if the Selection Tool could snap to pixels. As it is now it can be drawn over a pixel, making it a bit unreliable to know if the pixel will be part of the selection or not. Perhaps this could be an option in for the tool itself, or an option in the program settings.

lbalazscs commented 1 year ago

Instead of using selections, you can try using layer masks as a different way of working. You could use the Brush tool in "One Pixel" mode with anti-aliasing turned off in its settings to easily select individual pixels. Just paint with white to select and black to deselect. You can switch between foreground and background colors by pressing the X key. This workflow can be pretty fast once you get used to it.

I'm also thinking about adding the pixel snapping feature, but in general I think that layer masks are more flexible anyway.

Imerion commented 1 year ago

That is an interesting way of using layer masks - it could definitely come in handy in some situations. Thanks for the tip!

For this specific request the thing I need to do is usually to copy a larger part of a pixel drawing, for example if I have drawn half of a sprite and want to copy and then mirror it to create the other half, or if I need to quickly create 10 copies of a sprite to make small adjustments too each for an animation. For such cases a quick selection box would be faster.

lbalazscs commented 1 year ago

In the newest commit pixel snapping for selections is implemented in a crude way. There's no specific setting for it yet, and it has a problem (displaying the size of the selection is positioned incorrectly), but at least you can check if this helps you.

The change also affects the Shapes tool (at least during the initial drawing), this is most visible with the Rectangle shape. In the long term the Pen and Gradient tools should also have pixel snapping for consistency, and the Crop tool too (in this case regardless of the setting, since cropping always happens at the pixel level anyway).

Imerion commented 1 year ago

Thanks, that works great! Does exactly what I needed and it even works well when using "Convert to path" and then back to "Convert to selection", which I also use a great deal.

lbalazscs commented 1 year ago

In the latest version there's a "Snap Vector Tools to Pixels" checkbox in Preferences/Mouse. If this is enabled, then the selection, gradient, pen, and shapes tools should snap to the pixel grid. The "transform box" in the shapes and pen tools will only snap if it has not been rotated.

The crop and move tools should always snap, independently of the preferences (the move tool already snapped prior to these changes, only the crop tool's behavior is new).

Imerion commented 1 year ago

That is excellent, thanks! I have already have good use of the pixel snapping for selections, and will try this out as soon as possible. Thanks again! I believe this issue can be considered closed then.

lbalazscs commented 1 year ago

I typically close issues only when I create an "official" release that includes the corresponding fix or feature. However, it's OK if you choose to close it earlier, it's no big deal.

Imerion commented 1 year ago

That sounds better, in case someone comes in and look for a similar issue. I'll leave it be. :)

lbalazscs commented 1 year ago

This was implemented in the recently released version 4.3.1.