def draw
background(200);
# map, mouseX between 0 and 5.
ax = map(mouseX, 0, 100, 0, 5)
ay = 66
# Get the ceiling of the mapped number.
bx = ceil(map(mouseX, 0, 100, 0, 5))
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(format("%.2f", ax), ax, ay - 5)
text(format("%.1f", bx), bx, by - 5)
end
小数点以下を切り上げた値を計算します。
| 引数名 | 内容 | 備考 | オプション | デフォルト値 |
|---|---|---|---|---|
| n | 数値 |
切り上げられた値