HaikuArchives / ArtPaint

ArtPaint is a painting and image processing program.
https://haikuarchives.github.io/ArtPaint/
29 stars 18 forks source link

Rotate needs ability to set/reset pivot point to center/corners #459

Open humdingerb opened 1 year ago

humdingerb commented 1 year ago

Try this:

screenshot1

dsizzle commented 1 year ago

How did you rotate it? You need to make sure the rotation center is exactly centered so you don't shift the square by a half-pixel, which gives you that anti-aliased edge. That would also make it "101 x 101" because the half-pixels on the edges still take up a whole pixel.

I did this:

  1. created a 100x100 canvas and filled with green
  2. used Crop with -50, -50, 200, 200 to make sure the square was exactly centered,
  3. filled the edge around the green square with white.
  4. rotate Active Layer 90 degrees

rot90

The edge is perfectly crisp with no anti-aliasing.

humdingerb commented 1 year ago

I just created a square and rotated the (arbitrarily sized) layer.

Maybe my brain shortcircuits thinking about it, but... The rotating area width/height has either an odd or an even number of pixels. The rotation point is therefore either in the... hang on... I think I got it! The issue may be if the width has an even number of pixels and the height is odd, and vice-versa. See here:

rotation-centers

Let's say the checker pattern are single pixels of an image. If a rotating area has an even number of pixels in height and width, the rotation center lies in one of the green corners. If the pixel number is odd, it's in the center. But if one of them is even and the other odd, the rotation point is in one of the red circles, which will result in half-pixels.

Given the blurry results, should ArtPaint make sure the rotation point is in the "green" locations? I think so, because the artist probably isn't interested in the "mathematically correct" center.

dsizzle commented 1 year ago

I appreciate your analysis but thinking about it from a user perspective I am not able to come up with situations where it matters that much.

A. Any angle besides 90, 180, 270 will have an antialiased edge no matter the rotation center. B. Any shape that doesn’t have a flat edge aligned to 90, 180, 270, or 360 will be antialiased no matter the rotation center.

Between A & B the number of use cases seem quite small. Am I missing something?

I can see enhancements to help with setting rotation centers being useful, something like this widget(ignore the orange square)

27AE758E-DD60-4989-A75E-3FAA355AFB63

or a modifier key to snap the rotation center to the corner of a selection.

humdingerb commented 1 year ago

WRT that antialiasing, maybe you're right. Just caught my eye, probably because I often deal with straight, rel. low resolution lines of screenshots and mockups... :)

The idea to help setting the rotation center is a good one. Best IMO by snapping to selection/canvas corners, median lines, center when holding SHIFT while right-dragging the rotation-center-widget.

dsizzle commented 1 year ago

just playing around a bit, I think one area this is definitely needed is that there's no convenient way to reset the pivot point to the center of the selection, besides cancelling the rotation and reopening the manipulator.