Static p5_sys::global::setMoveThreshold[][src]

pub static setMoveThreshold: SetMoveThresholdInternalType
Expand description

The setMoveThreshold() function is used to set the movement threshold for the deviceMoved() function. The default threshold is set to 0.5.

Examples

// Run this example on a mobile device
// You will need to move the device incrementally further
// the closer the square's color gets to white in order to change the value.

let value = 0;
let threshold = 0.5;
function setup() {
  setMoveThreshold(threshold);
}
function draw() {
  fill(value);
  rect(25, 25, 50, 50);
}
function deviceMoved() {
  value = value + 5;
  threshold = threshold + 0.1;
  if (value > 255) {
    value = 0;
    threshold = 30;
  }
  setMoveThreshold(threshold);
}

Parameters

value The threshold value