pub static ceil: CeilInternalTypeExpand description
Calculates the closest int value that is greater than or equal to the value of the parameter. Maps to Math.ceil(). For example, ceil(9.03) returns the value 10.
Examples
function draw() {
background(200);
// map, mouseX between 0 and 5.
let ax = map(mouseX, 0, 100, 0, 5);
let ay = 66;
//Get the ceiling of the mapped number.
let bx = ceil(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 up