p5 numbers that movep5 會動的數值
env('kick'), spring(), speed() and count('kick', 4) shape a number the way TouchDesigner's Trigger, Spring, Speed and Count CHOPs do: a bass drum opens a disc, a spring bounces it back, a hand turns, every fourth kick changes the colour.env('kick')、spring()、speed()、count('kick', 4) 像 TouchDesigner 的 Trigger、Spring、Speed、Count 那樣讓數值動起來:大鼓撐開圓盤、彈簧把它彈回來、指針一直轉、每 4 下大鼓換一個顏色。
Try these three things試試這三件事
- Nothing to plug in: startDrums() plays its own kicks, and the disc opens on each one and bounces back (the scope in the corner draws the bounce).
- Watch the four dots under the centre: count('kick', 4) walks 0 1 2 3, and every fourth kick the colour changes.
- Press space or click the canvas: trigger('boom') is an event of your own, and env('boom') sends a ring out.
- 不用接任何東西:startDrums() 自己打大鼓,圓盤每一下撐開、再彈回來(角落的示波器畫出那個彈跳)。
- 看圓心下面四顆點:count('kick', 4) 數 0 1 2 3,每數滿 4 下大鼓就換一個顏色。
- 按空白鍵或點一下畫面:trigger('boom') 是你自己的事件,env('boom') 讓一圈往外推。
Needs: Microphone.需要:麥克風。
No hardware? Use Drum machine.沒有硬體?用鼓機。
Read these lines讀這幾行
sketch.js:24–25 env() is 1 right after each kick and 0 again 0.3 s later; spring() makes the radius follow it like a mass on a spring.env() 在每下大鼓之後是 1,0.3 秒後回到 0;spring() 讓半徑像彈簧上的重物那樣追著它。sketch.js:26–28 speed() adds to the angle every second; count('kick', 4) walks 0 to 3, count('kick') is the total, so total ÷ 4 is the colour.speed() 每秒替角度加一點;count('kick', 4) 數 0 到 3,count('kick') 是總數,總數除以 4 就是顏色。sketch.js:62–63 trigger('boom') is an event of the sketch's own: env('boom') above is what hears it.trigger('boom') 是草圖自己的事件,上面的 env('boom') 接它。
In the docs文件裡: Values over time: lag, env, speed, spring, trail數值隨時間:lag、env、speed、spring、trail
Next: 26 p5 rhythm lab →下一個:26 p5 節奏實驗台 →
All examples所有範例