File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
src/data/examples/en/00_Structure Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
2
* @name Loop
3
3
* @arialabel Horizontal white line on a black background that moves from the bottom to the top of the screen parallel to the x-axis
4
- * @description The code inside the draw() function runs continuously from top
5
- * to bottom until the program is stopped.
4
+ * @description If noLoop() is run in setup(), the code in draw()
5
+ * is only run once. In this example, click the mouse
6
+ * to run the loop() function to cause the draw() the
7
+ * run continuously.
6
8
*/
7
- let y = 100 ;
9
+ let y = 0 ;
8
10
9
11
// The statements in the setup() function
10
12
// execute once when the program begins
11
13
function setup ( ) {
12
14
createCanvas ( 720 , 400 ) ; // Size must be the first statement
13
15
stroke ( 255 ) ; // Set line drawing color to white
14
16
frameRate ( 30 ) ;
17
+ noLoop ( ) ;
15
18
}
16
19
// The statements in draw() are executed until the
17
20
// program is stopped. Each statement is executed in
@@ -25,3 +28,7 @@ function draw() {
25
28
}
26
29
line ( 0 , y , width , y ) ;
27
30
}
31
+
32
+ function mousePressed ( ) {
33
+ loop ( ) ;
34
+ }
You can’t perform that action at this time.
0 commit comments