On Mon, 28 Mar 2022 17:47:50 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:

> > I also think there's at least some analogy with OpenJFX's snap-to-pixel 
> > idea that it is sometimes better to pick a pixel and stick with it rather 
> > than span pixels and be fuzzy. Not an expert on the details of that by any 
> > means @kevinrushforth might be able to point to something if it is relevant.
> 
> I wonder how it's handled in OpenJFX. There should be the same problem with 
> borders at fractional scales.
> 
> > If we figure this out properly it might be useful to apply to other cases 
> > rather than applying inconsistent hacks.

JavaFX implements snap-to-pixel by default for Region (which is the base class 
of all layout panes and UI controls). This is done by either doing a round, 
floor, or ceil operation by first scaling the user-space value (by the screen 
scale), rounding (or floor or ceil) in screen coords, and then dividing by the 
scale to get it back to user space. For region borders, we snap all four 
corners of each border to pixels. The stroke width is scaled, so that a border 
of 1 will show up as 3 pixels with a screen scale of 3.

I don't know whether you could do anything analagous in Java2D.

-------------

PR: https://git.openjdk.java.net/jdk/pull/7449

Reply via email to