函数 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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。