OAVp5.chop.reset()#
functionoav-p5OAVp5.chop.reset([name])
Forgets the memory named name (a lag, a speed total, a count …), or every memory when you give no name: the next call starts fresh.
The call that follows starts from nothing, as if it were the first one: a speed() total is 0 again, a lag() takes its input as it is, a count() is back at 0. Use it to restart a named effect, for example on a key press.
Calling it with no name also drops the unnamed memories. They are made again by order on the next frame, so nothing breaks, but every unnamed value starts over too. Event counts from trigger() are not memories of a call and are not touched.
Parameters
| Name | Type | Description |
|---|---|---|
name | String | The name you gave a call as its last argument ('spin' in speed(1, 'spin')). The memory of that name is forgotten in every function that has one. Left out, every memory is forgotten, named or not. optional |
Examples
function setup() {
createCanvas(400, 300);
}
function mousePressed() {
OAVp5.chop.reset('spin'); // forget the named speed
}
function draw() {
background(20);
translate(width / 2, height / 2);
rotate(speed(1, 'spin'));
rect(-40, -40, 80, 80);
}Related
OAVp5.chop.slots()Lists every memory the CHOP functions are using right now: its kind, how it is found, and its latest value.OAVp5.chopThe CHOP functions under one roof, plus the state of the module behind them:OAVp5.chop.lag(…),.state,.slots(),.reset().speed()Addsrateto a running total every second, sorotate(speed(TWO_PI))turns once a second and the rate can change without the total ever jumping.count()Counts how oftenonhas turned on, or how many'kick'(or any other event) have happened; with a limit it loops 0, 1, … limit − 1.