Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing examples for acceleration functions #2867

Merged
merged 1 commit into from
May 10, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions src/events/acceleration.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,38 @@ var shake_threshold = 30;
*
* @method setMoveThreshold
* @param {number} value The threshold value
* @example
* <div class="norender">
* <code>
* // 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.
*
* var value = 0;
* var 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);
* }
* </code>
* </div>
*
* @alt
* 50x50 black rect in center of canvas. turns white on mobile when device moves
*/

p5.prototype.setMoveThreshold = function(val) {
p5._validateParameters('setMoveThreshold', arguments);
move_threshold = val;
Expand All @@ -365,7 +396,39 @@ p5.prototype.setMoveThreshold = function(val) {
*
* @method setShakeThreshold
* @param {number} value The threshold value
* @example
* <div class="norender">
* <code>
* // Run this example on a mobile device
* // You will need to shake the device more firmly
* // the closer the box's fill gets to white in order to change the value.
*
* var value = 0;
* var threshold = 30;
* function setup() {
* setShakeThreshold(threshold);
* }
* function draw() {
* fill(value);
* rect(25, 25, 50, 50);
* }
* function deviceMoved() {
* value = value + 5;
* threshold = threshold + 5;
* if (value > 255) {
* value = 0;
* threshold = 30;
* }
* setShakeThreshold(threshold);
* }
* </code>
* </div>
*
* @alt
* 50x50 black rect in center of canvas. turns white on mobile when device
* is being shaked
*/

p5.prototype.setShakeThreshold = function(val) {
p5._validateParameters('setShakeThreshold', arguments);
shake_threshold = val;
Expand Down