On Sun, 16 Aug 2026 17:26:03 GMT, Nir Lisker <[email protected]> wrote:
>> Pixel snapping is really hard to get right (in fact, it's so hard that even >> JavaFX itself gets it wrong in so many places). >> I've compiled a list of things that I've learned, because there isn't really >> any good documentation as of yet. >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > modules/javafx.graphics/src/main/java/javafx/scene/layout/package-info.java > line 409: > >> 407: * The same rule applies to distinct margins and gaps: snap >> each one with {@code snapSpaceX/Y}, then re-snap >> 408: * the final sum with {@code snapSpaceX/Y} again. For more >> information, refer to <em>Re-snap after >> 409: * calculations, using the meaning of the result</em>. > > This referred-to section hasn't appeared yet. > Suggestion: > > * the final sum with {@code snapSpaceX/Y} again. For more > information, refer to <em>Re-snap after > * calculations, using the meaning of the result</em> below. Additionally, I think this "for more information" part appears too late. I'd think it belongs in the section above about classification since it looks like a direct contradiction to what it wrote (sizes are snapped with `space` suddenly). The rules about snapping a sum of snapped numbers it split between sections. For sizes, it is explained both here and in *Re-snapping* (use `snapSpace`), gaps/spaces are explained here (use `snapSpace`), and coordinates are explained in *Re-snapping* (use `snapPosition`): * The final {@code snapSpaceX} does not mean that the allocated width is empty space, it merely uses * the snapping method to remove a tiny amount of floating-point drift. * <p> * The same principle applies to coordinates: after calculating a final coordinate from snapped values, use * {@code snapPositionX/Y} to remove potential floating-point drift. I'd put all 3 of them in one place before they are used and avoid the repetition. I'll note that it was mentioned previously in *Choosing the snapping operation* with <li>{@code snapSpaceX/Y} can also be used to remove floating-point drift from the result of a computation. so the point about removing floating-point drift is now in 3 places. ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/2260#discussion_r3792477031
