Static p5_sys::global::floor [−][src]
pub static floor: FloorInternalType
Expand description
Calculates the closest int value that is less than or equal to the value of the parameter. Maps to Math.floor().
Examples
function draw() { background(200); //map, mouseX between 0 and 5. let ax = map(mouseX, 0, 100, 0, 5); let ay = 66; //Get the floor of the mapped number. let bx = floor(map(mouseX, 0, 100, 0, 5)); let by = 33; // Multiply the mapped numbers by 20 to more easily // see the changes. stroke(0); fill(0); line(0, ay, ax * 20, ay); line(0, by, bx * 20, by); // Reformat the float returned by map and draw it. noStroke(); text(nfc(ax, 2), ax, ay - 5); text(nfc(bx, 1), bx, by - 5); }
Parameters
n
number to round down