Skip to content

Commit c84d0c8

Browse files
author
lauren mccarthy
committed
updating docs for preload and noloop closes #409
1 parent 5b447b7 commit c84d0c8

File tree

4 files changed

+51
-13
lines changed

4 files changed

+51
-13
lines changed

lib/p5.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! p5.js v0.3.10 October 21, 2014 */
1+
/*! p5.js v0.3.10 October 28, 2014 */
22
var shim = function (require) {
33
window.requestDraw = function () {
44
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback, element) {
@@ -2025,7 +2025,7 @@ var environment = function (require, core, constants) {
20252025
C.WAIT
20262026
];
20272027
p5.prototype._frameRate = 0;
2028-
p5.prototype._lastFrameTime = 0;
2028+
p5.prototype._lastFrameTime = new Date().getTime();
20292029
p5.prototype._targetFrameRate = 60;
20302030
p5.prototype.frameCount = 0;
20312031
p5.prototype.focused = true;

lib/p5.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/core.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,14 @@ define(function (require) {
5454
* var c;
5555
* function preload() { // preload() runs once
5656
* img = loadImage('assets/laDefense.jpg');
57-
* noLoop();
5857
* }
58+
*
5959
* function setup() { // setup() waits until preload() is done
6060
* img.loadPixels();
6161
* // get color of middle pixel
6262
* c = img.get(img.width/2, img.height/2);
6363
* }
64+
*
6465
* function draw() {
6566
* background(c);
6667
* image(img, 25, 25, 50, 50);

src/structure/structure.js

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,59 @@ define(function (require) {
1414
throw 'exit() not implemented, see remove()';
1515
};
1616
/**
17-
* Stops p5.js from continuously executing the code within draw(). If loop()
18-
* is called, the code in draw() begins to run continuously again. If using
19-
* noLoop() in setup(), it should be the last line inside the block.
17+
* <p>Stops p5.js from continuously executing the code within draw().
18+
* If loop() is called, the code in draw() begins to run continuously again.
19+
* If using noLoop() in setup(), it should be the last line inside the block.
20+
* </p>
2021
*
21-
* When noLoop() is used, it's not possible to manipulate or access the
22+
* <p>When noLoop() is used, it's not possible to manipulate or access the
2223
* screen inside event handling functions such as mousePressed() or
2324
* keyPressed(). Instead, use those functions to call redraw() or loop(),
2425
* which will run draw(), which can update the screen properly. This means
2526
* that when noLoop() has been called, no drawing can happen, and functions
26-
* like saveFrame() or loadPixels() may not be used.
27+
* like saveFrame() or loadPixels() may not be used.</p>
2728
*
28-
* Note that if the sketch is resized, redraw() will be called to update the
29-
* sketch, even after noLoop() has been specified. Otherwise, the sketch
30-
* would enter an odd state until loop() was called.
29+
* <p>Note that if the sketch is resized, redraw() will be called to update
30+
* the sketch, even after noLoop() has been specified. Otherwise, the sketch
31+
* would enter an odd state until loop() was called.</p>
3132
*
3233
* @method noLoop
34+
* @example
35+
* <div><code>
36+
* function setup() {
37+
* createCanvas(100, 100);
38+
* background(200);
39+
* noLoop();
40+
* }
41+
42+
* function draw() {
43+
* line(10, 10, 90, 90);
44+
* }
45+
* </code></div>
46+
*
47+
* <div><code>
48+
* var x = 0;
49+
* function setup() {
50+
* createCanvas(100, 100);
51+
* }
52+
*
53+
* function draw() {
54+
* background(204);
55+
* x = x + 0.1;
56+
* if (x > width) {
57+
* x = 0;
58+
* }
59+
* line(x, 0, x, height);
60+
* }
61+
*
62+
* function mousePressed() {
63+
* noLoop();
64+
* }
65+
*
66+
* function mouseReleased() {
67+
* loop();
68+
* }
69+
* </code></div>
3370
*/
3471
p5.prototype.noLoop = function() {
3572
this._loop = false;

0 commit comments

Comments
 (0)