// Wrap a signed pixel or lattice coordinate into a repeating axis of positive integer width. pub fn periodic_index(position: i64, width: i64) -> i64 { if width <= 0 { return -1; } let offset = position%width; if offset<0 { return offset+width; } offset }