@@ -353,7 +353,38 @@ var shake_threshold = 30;
353
353
*
354
354
* @method setMoveThreshold
355
355
* @param {number } value The threshold value
356
+ * @example
357
+ * <div class="norender">
358
+ * <code>
359
+ * // Run this example on a mobile device
360
+ * // You will need to move the device incrementally further
361
+ * // the closer the square's color gets to white in order to change the value.
362
+ *
363
+ * var value = 0;
364
+ * var threshold = 0.5;
365
+ * function setup() {
366
+ * setMoveThreshold(threshold);
367
+ * }
368
+ * function draw() {
369
+ * fill(value);
370
+ * rect(25, 25, 50, 50);
371
+ * }
372
+ * function deviceMoved() {
373
+ * value = value + 5;
374
+ * threshold = threshold + 0.1;
375
+ * if (value > 255) {
376
+ * value = 0;
377
+ * threshold = 30;
378
+ * }
379
+ * setMoveThreshold(threshold);
380
+ * }
381
+ * </code>
382
+ * </div>
383
+ *
384
+ * @alt
385
+ * 50x50 black rect in center of canvas. turns white on mobile when device moves
356
386
*/
387
+
357
388
p5 . prototype . setMoveThreshold = function ( val ) {
358
389
p5 . _validateParameters ( 'setMoveThreshold' , arguments ) ;
359
390
move_threshold = val ;
@@ -365,7 +396,39 @@ p5.prototype.setMoveThreshold = function(val) {
365
396
*
366
397
* @method setShakeThreshold
367
398
* @param {number } value The threshold value
399
+ * @example
400
+ * <div class="norender">
401
+ * <code>
402
+ * // Run this example on a mobile device
403
+ * // You will need to shake the device more firmly
404
+ * // the closer the box's fill gets to white in order to change the value.
405
+ *
406
+ * var value = 0;
407
+ * var threshold = 30;
408
+ * function setup() {
409
+ * setShakeThreshold(threshold);
410
+ * }
411
+ * function draw() {
412
+ * fill(value);
413
+ * rect(25, 25, 50, 50);
414
+ * }
415
+ * function deviceMoved() {
416
+ * value = value + 5;
417
+ * threshold = threshold + 5;
418
+ * if (value > 255) {
419
+ * value = 0;
420
+ * threshold = 30;
421
+ * }
422
+ * setShakeThreshold(threshold);
423
+ * }
424
+ * </code>
425
+ * </div>
426
+ *
427
+ * @alt
428
+ * 50x50 black rect in center of canvas. turns white on mobile when device
429
+ * is being shaked
368
430
*/
431
+
369
432
p5 . prototype . setShakeThreshold = function ( val ) {
370
433
p5 . _validateParameters ( 'setShakeThreshold' , arguments ) ;
371
434
shake_threshold = val ;
0 commit comments