Skip to main content

snap_block_height

Function snap_block_height 

Source
pub fn snap_block_height(height_px: f32) -> f32
Expand description

A block’s height is constrained to 2 * PIN_TOP_MARGIN + h * PIN_PITCH for an unsigned h: a PIN_TOP_MARGIN above the top pin slot and below the bottom one, plus one PIN_PITCH per added slot. So a height-h block holds h + 1 pins, at offsets 0..=h (and max_pin_slot of this height is exactly h). This rounds a raw pixel height to the nearest such valid height, floored at the h = 0 minimum of 2 * PIN_TOP_MARGIN.