open-audiovisual
Search GitHub

oav-p5 reference · Values over time (CHOP)

OAVp5.chop.reset()#

functionoav-p5
OAVp5.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

NameTypeDescription
nameStringThe 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

jsOpenProcessing ↗
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);
}
The square turns steadily. Click: it jumps back to its starting angle and carries on from there.

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.chop The CHOP functions under one roof, plus the state of the module behind them: OAVp5.chop.lag(…), .state, .slots(), .reset().
  • speed() Adds rate to a running total every second, so rotate(speed(TWO_PI)) turns once a second and the rate can change without the total ever jumping.
  • count() Counts how often on has turned on, or how many 'kick' (or any other event) have happened; with a limit it loops 0, 1, … limit − 1.

p5/oav-p5.js, line 2884

↑ Back to top · All names