pub const GUI_ROUNDING: f32 = _; // 0.03125f32
Expand description
We (sometimes) round sizes and coordinates to an even multiple of this value.
This is only used for rounding logical UI points, used for widget coordinates and sizes.
When rendering, you may want to round to an integer multiple of the physical pixels instead,
using GuiRounding::round_to_pixels
.
See GuiRounding::round_ui
for more information.
This constant has to be a (negative) power of two so that it can be represented exactly by a floating point number.
If we pick too large a value (e.g. 1 or 1/2), then we get judder during scrolling and animations. If we pick too small a value (e.g. 1/4096), we run the risk of rounding errors again.
f32
has 23 bits of mantissa, so if we use e.g. 1/8 as the rounding factor,
we can represent all numbers up to 2^20 exactly, which is plenty
(to my knowledge there are no displays that are a million pixels wide).