函數 setMoveThreshold() 用於設置 deviceMoved() 函數的移動閾值。默認閾值設置為 0.5。
用法:
setMoveThreshold(value)
參數:該函數接受如上所述和以下描述的單個參數。
- value:它是一個數字,表示閾值。
例:
Javascript
// Run this example on a mobile device
// You will need to move the device incrementally further
let value = 0;
let threshold = 0.5;
function setup() {
// The function in which we pass the thresold value as default.
setMoveThreshold(threshold);
}
function draw() {
fill(value);
ellipse(56, 46, 55, 55);
}
function deviceMoved() {
value = value + 7;
// increment in the threshold.
threshold = threshold + 0.1;
if (value > 255) {
value = 0;
threshold = 30;
}
//Again set the threshold function.
setMoveThreshold(threshold);
}
輸出:
相關用法
- PHP imagecreatetruecolor()用法及代碼示例
- p5.js year()用法及代碼示例
- d3.js d3.utcTuesdays()用法及代碼示例
- PHP ImagickDraw getTextAlignment()用法及代碼示例
- PHP Ds\Sequence last()用法及代碼示例
- PHP geoip_continent_code_by_name()用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- PHP GmagickPixel setcolor()用法及代碼示例
- Tensorflow.js tf.layers.embedding()用法及代碼示例
- PHP opendir()用法及代碼示例
- PHP cal_to_jd()用法及代碼示例
- d3.js d3.bisectLeft()用法及代碼示例
- PHP stream_get_transports()用法及代碼示例
注:本文由純淨天空篩選整理自_sh_pallavi大神的英文原創作品 p5.js setMoveThreshold() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。