pad()#
functionoav-p5pad(n)
Returns how hard pad number n is pressed, 0 to 1: the same as pad1 to pad16, for any n.
The function form of pad1.
Parameters
| Name | Type | Description |
|---|---|---|
n | Number | Which pad, counting from 1. |
Returns
Number The velocity while the pad is held (0..1), 0 when it is released.
Examples
function setup() {
createCanvas(400, 300);
noStroke();
}
function draw() {
background(20);
for (let i = 1; i <= 8; i++) {
fill(255, 90, 31, 60 + pad(i) * 195);
square(20 + ((i - 1) % 4) * 92, 40 + floor((i - 1) / 4) * 110, 80);
}
}Related
pad1How hard a drum pad is pressed, from 0 to 1:pad1is the first pad, up topad16; 0 when it is let go.knob()Returns the position of knob numbern, from 0 to 1: the same asknob1toknob8, for anyn.padPressed()You define this function; oav-p5 calls it each time a drum pad is hit.