def draw
background(200)
leftWall = 25
rightWall = 75
# xm is just the mouseX, while
# xc is the mouseX, but constrained
# between the leftWall and rightWall!
xm = mouseX
xc = constrain(mouseX, leftWall, rightWall)
# Draw the walls.
stroke(150)
line(leftWall, 0, leftWall, height)
line(rightWall, 0, rightWall, height)
# Draw xm and xc as circles.
noStroke
fill(150)
ellipse(xm, 33, 9, 9) # Not Constrained
fill(0)
ellipse(xc, 66, 9, 9) # Constrained
end
値の取りうる範囲を下限値と上限値で制限します。
| 引数名 | 内容 | 備考 | オプション | デフォルト値 |
|---|---|---|---|---|
| n | 値 | |||
| low | 下限値 | |||
| high | 上限値 |
制限された値