sqrt

概要

p5.jsリファレンス(参考情報)

[p5.js] sqrt

サンプル

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

構文

戻値