torus

def setup
  createCanvas(100, 100, WEBGL)
end

def draw
  background(205, 102, 94)
  rotateX(frameCount * 0.02)
  rotateY(frameCount * 0.02)
  torus(30, 15)
end
def setup
  createCanvas(100, 100, WEBGL)
  @detailX = createSlider(3, 24, 3)
  @detailX.position(10, height + 5)
  @detailX.style('width', '80px')
end

def draw
  background(205, 102, 94)
  rotateY(millis / 1000)
  torus(30, 15, @detailX.value, 12)
end
def setup
  createCanvas(100, 100, WEBGL)
  @detailY = createSlider(3, 16, 3)
  @detailY.position(10, height + 5)
  @detailY.style('width', '80px')
end

def draw
  background(205, 102, 94)
  rotateY(millis / 1000)
  torus(30, 15, 16, @detailY.value)
end

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

[p5.js] torus

概要

円環を描画します。

書式

torus([radius] [, tubeRadius] [, detailX] [, detailY])

引数

引数名内容備考オプションデフォルト値
radius円環全体の半径50
tubeRadius円環のチューブの半径10
detailXx方向の細分割数24
detailYy方向の細分割数16

戻値

なし

備考

関連