def draw
background(200)
eSize = 7
x1 = mouseX
y1 = 80
x2 = sqrt(x1)
y2 = 20
# Draw the non-squared.
line(0, y1, width, y1)
ellipse(x1, y1, eSize, eSize)
# Draw the squared.
line(0, y2, width, y2)
ellipse(x2, y2, eSize, eSize)
# Draw dividing line.
stroke(100)
line(0, height / 2, width, height / 2)
# Draw text.
noStroke
fill(0)
spacing = 15
text("x = #{x1}", 0, y1 + spacing)
text("sqrt(x) = #{x2}", 0, y2 + spacing)
end
平方根を計算します。
| 引数名 | 内容 | 備考 | オプション | デフォルト値 |
|---|---|---|---|---|
| n | 数値 | 0以上の値 |
平方根の値