* @module Structure * @submodule Structure * @for p5
(p5, fn)
| 5 | */ |
| 6 | |
| 7 | function structure(p5, fn){ |
| 8 | /** |
| 9 | * Stops the code in <a href="#/p5/draw">draw()</a> from running repeatedly. |
| 10 | * |
| 11 | * By default, <a href="#/p5/draw">draw()</a> tries to run 60 times per |
| 12 | * second. Calling `noLoop()` stops <a href="#/p5/draw">draw()</a> from |
| 13 | * repeating. The draw loop can be restarted by calling |
| 14 | * <a href="#/p5/loop">loop()</a>. <a href="#/p5/draw">draw()</a> can be run |
| 15 | * once by calling <a href="#/p5/redraw">redraw()</a>. |
| 16 | * |
| 17 | * The <a href="#/p5/isLooping">isLooping()</a> function can be used to check |
| 18 | * whether a sketch is looping, as in `isLooping() === true`. |
| 19 | * |
| 20 | * @method noLoop |
| 21 | * |
| 22 | * @example |
| 23 | * function setup() { |
| 24 | * createCanvas(100, 100); |
| 25 | * |
| 26 | * // Turn off the draw loop. |
| 27 | * noLoop(); |
| 28 | * |
| 29 | * describe('A white half-circle on the left edge of a gray square.'); |
| 30 | * } |
| 31 | * |
| 32 | * function draw() { |
| 33 | * background(200); |
| 34 | * |
| 35 | * // Calculate the circle's x-coordinate. |
| 36 | * let x = frameCount; |
| 37 | * |
| 38 | * // Draw the circle. |
| 39 | * // Normally, the circle would move from left to right. |
| 40 | * circle(x, 50, 20); |
| 41 | * } |
| 42 | * |
| 43 | * @example |
| 44 | * // Double-click to stop the draw loop. |
| 45 | * |
| 46 | * function setup() { |
| 47 | * createCanvas(100, 100); |
| 48 | * |
| 49 | * // Slow the frame rate. |
| 50 | * frameRate(5); |
| 51 | * |
| 52 | * describe('A white circle moves randomly on a gray background. It stops moving when the user double-clicks.'); |
| 53 | * } |
| 54 | * |
| 55 | * function draw() { |
| 56 | * background(200); |
| 57 | * |
| 58 | * // Calculate the circle's coordinates. |
| 59 | * let x = random(0, 100); |
| 60 | * let y = random(0, 100); |
| 61 | * |
| 62 | * // Draw the circle. |
| 63 | * // Normally, the circle would move from left to right. |
| 64 | * circle(x, y, 20); |
no test coverage detected