-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
Copy pathreference.js
2159 lines (2145 loc) · 51.5 KB
/
reference.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* @module Foundation
* @submodule Foundation
* @for p5
*/
/**
* Declares a new variable.
*
* A variable is a container for a value. For example, a variable might
* contain a creature's x-coordinate as a `Number` or its name as a
* `String`. Variables can change value by reassigning them as follows:
*
* ```js
* // Declare the variable x and assign it the value 10.
* let x = 10;
*
* // Reassign x to 50.
* x = 50;
* ```
*
* Variables have block scope. When a variable is declared between curly
* braces `{}`, it only exists within the block defined by those braces. For
* example, the following code would throw a `ReferenceError` because `x` is
* declared within the `setup()` function's block:
*
* ```js
* function setup() {
* createCanvas(100, 100);
*
* let x = 50;
* }
*
* function draw() {
* background(200);
*
* // x was declared in setup(), so it can't be referenced here.
* circle(x, 50, 20);
* }
* ```
*
* Variables declared outside of all curly braces `{}` are in the global
* scope. A variable that's in the global scope can be used and changed
* anywhere in a sketch:
*
* ```js
* let x = 50;
*
* function setup() {
* createCanvas(100, 100);
* }
*
* function draw() {
* background(200);
*
* // Change the value of x.
* x += 10;
*
* circle(x, 50, 20);
* }
* ```
*
* @property let
*
* @example
* <div>
* <code>
* function setup() {
* createCanvas(100, 100);
*
* background(220);
*
* // Style the text.
* textAlign(CENTER);
* textSize(16);
*
* // Create the message variable.
* let message = 'Hello, 🌍!';
*
* // Display the message.
* text(message, 50, 50);
*
* describe('The text "Hello, 🌍!" written on a gray background.');
* }
* </code>
* </div>
*
* <div>
* <code>
* let x = 0;
*
* function setup() {
* createCanvas(100, 100);
*
* describe('A white circle moves from left to right against a gray background.');
* }
*
* function draw() {
* background(220);
*
* // Change the value of x.
* x += 1;
*
* circle(x, 50, 20);
* }
* </code>
* </div>
*/
/**
* A way to choose whether to run a block of code.
*
* `if` statements are helpful for running a block of code based on a
* condition. For example, an `if` statement makes it easy to express the
* idea "Draw a circle if the mouse is pressed.":
*
* ```js
* if (mouseIsPressed === true) {
* circle(mouseX, mouseY, 20);
* }
* ```
*
* The statement header begins with the keyword `if`. The expression in
* parentheses `mouseIsPressed === true` is a `Boolean` expression that's
* either `true` or `false`. The code between the curly braces `{}` is the if
* statement's body. The body only runs if the `Boolean` expression is `true`.
*
* The <a href="#/p5/mouseIsPressed">mouseIsPressed</a> system variable is
* always `true` or `false`, so the code snippet above could also be written
* as follows:
*
* ```js
* if (mouseIsPressed) {
* circle(mouseX, mouseY, 20);
* }
* ```
*
* An `if`-`else` statement adds a block of code that runs if the `Boolean`
* expression is `false`. For example, here's an `if`-`else` statement that
* expresses the idea "Draw a circle if the mouse is pressed. Otherwise,
* display a message.":
*
* ```js
* if (mouseIsPressed === true) {
* // When true.
* circle(mouseX, mouseY, 20);
* } else {
* // When false.
* text('Click me!', 50, 50);
* }
* ```
*
* There are two possible paths, or branches, in this code snippet. The
* program must follow one branch or the other.
*
* An `else`-`if` statement makes it possible to add more branches.
* `else`-`if` statements run different blocks of code under different
* conditions. For example, an `else`-`if` statement makes it easy to express
* the idea "If the mouse is on the left, paint the canvas white. If the mouse
* is in the middle, paint the canvas gray. Otherwise, paint the canvas
* black.":
*
* ```js
* if (mouseX < 33) {
* background(255);
* } else if (mouseX < 67) {
* background(200);
* } else {
* background(0);
* }
* ```
*
* `if` statements can add as many `else`-`if` statements as needed. However,
* there can only be one `else` statement and it must be last.
*
* `if` statements can also check for multiple conditions at once. For
* example, the `Boolean` operator `&&` (AND) checks whether two expressions
* are both `true`:
*
* ```js
* if (keyIsPressed === true && key === 'p') {
* text('You pressed the "p" key!', 50, 50);
* }
* ```
*
* If the user is pressing a key AND that key is `'p'`, then a message will
* display.
*
* The `Boolean` operator `||` (OR) checks whether at least one of two
* expressions is `true`:
*
* ```js
* if (keyIsPressed === true || mouseIsPressed === true) {
* text('You did something!', 50, 50);
* }
* ```
*
* If the user presses a key, or presses a mouse button, or both, then a
* message will display.
*
* The body of an `if` statement can contain another `if` statement. This is
* called a "nested `if` statement." For example, nested `if` statements make
* it easy to express the idea "If a key is pressed, then check if the key is
* `'r'`. If it is, then set the fill to red.":
*
* ```js
* if (keyIsPressed === true) {
* if (key === 'r') {
* fill('red');
* }
* }
* ```
*
* See <a href="#/p5/Boolean">Boolean</a> and <a href="#/p5/Number">Number</a>
* to learn more about these data types and the operations they support.
*
* @property if
*
* @example
* <div>
* <code>
* // Click the mouse to show the circle.
*
* function setup() {
* createCanvas(100, 100);
*
* describe(
* 'A white circle on a gray background. The circle follows the mouse user clicks on the canvas.'
* );
* }
*
* function draw() {
* background(200);
*
* if (mouseIsPressed === true) {
* circle(mouseX, mouseY, 20);
* }
* }
* </code>
* </div>
*
* <div>
* <code>
* // Click the mouse to show different shapes.
*
* function setup() {
* createCanvas(100, 100);
*
* describe(
* 'A white ellipse on a gray background. The ellipse becomes a circle when the user presses the mouse.'
* );
* }
*
* function draw() {
* background(200);
*
* if (mouseIsPressed === true) {
* circle(50, 50, 20);
* } else {
* ellipse(50, 50, 20, 50);
* }
* }
* </code>
* </div>
*
* <div>
* <code>
* // Move the mouse to change the background color.
*
* function setup() {
* createCanvas(100, 100);
*
* describe(
* 'A square changes color from white to black as the user moves the mouse from left to right.'
* );
* }
*
* function draw() {
* if (mouseX < 33) {
* background(255);
* } else if (mouseX < 67) {
* background(200);
* } else {
* background(0);
* }
* }
* </code>
* </div>
*
* <div>
* <code>
* // Click on the canvas to begin detecting key presses.
*
* function setup() {
* createCanvas(100, 100);
*
* describe(
* 'A white circle drawn on a gray background. The circle changes color to red when the user presses the "r" key.'
* );
* }
*
* function draw() {
* background(200);
*
* if (keyIsPressed === true) {
* if (key === 'r') {
* fill('red');
* }
* }
*
* circle(50, 50, 40);
* }
* </code>
* </div>
*/
/**
* A named group of statements.
*
* <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions" target="_blank">Functions</a>
* help with organizing and reusing code. For example, functions make it easy
* to express the idea "Draw a flower.":
*
* ```js
* function drawFlower() {
* // Style the text.
* textAlign(CENTER, CENTER);
* textSize(20);
*
* // Draw a flower emoji.
* text('🌸', 50, 50);
* }
* ```
*
* The function header begins with the keyword `function`. The function's
* name, `drawFlower`, is followed by parentheses `()` and curly braces `{}`.
* The code between the curly braces is called the function's body. The
* function's body runs when the function is called like so:
*
* ```js
* drawFlower();
* ```
*
* Functions can accept inputs by adding parameters to their headers.
* Parameters are placeholders for values that will be provided when the
* function is called. For example, the `drawFlower()` function could include
* a parameter for the flower's size:
*
* ```js
* function drawFlower(size) {
* // Style the text.
* textAlign(CENTER, CENTER);
*
* // Use the size parameter.
* textSize(size);
*
* // Draw a flower emoji.
* text('🌸', 50, 50);
* }
* ```
*
* Parameters are part of the function's declaration. Arguments are provided
* by the code that calls a function. When a function is called, arguments are
* assigned to parameters:
*
* ```js
* // The argument 20 is assigned to the parameter size.
* drawFlower(20);
* ```
*
* Functions can have multiple parameters separated by commas. Parameters
* can have any type. For example, the `drawFlower()` function could accept
* `Number` parameters for the flower's x- and y-coordinates along with its
* size:
*
* ```js
* function drawFlower(x, y, size) {
* // Style the text.
* textAlign(CENTER, CENTER);
*
* // Use the size parameter.
* textSize(size);
*
* // Draw a flower emoji.
* // Use the x and y parameters.
* text('🌸', x, y);
* }
* ```
*
* Functions can also produce outputs by adding a `return` statement:
*
* ```js
* function double(x) {
* let answer = 2 * x;
* return answer;
* }
* ```
*
* The expression following `return` can produce an output that's used
* elsewhere. For example, the output of the `double()` function can be
* assigned to a variable:
*
* ```js
* let six = double(3);
* text(`3 x 2 = ${six}`, 50, 50);
* ```
*
* @property function
*
* @example
* <div>
* <code>
* function setup() {
* createCanvas(100, 100);
*
* describe('A pink flower on a gray background.');
* }
*
* function draw() {
* background(200);
*
* // Call the drawFlower() function.
* drawFlower();
* }
*
* // Declare a function that draws a flower at the
* // center of the canvas.
* function drawFlower() {
* // Style the text.
* textAlign(CENTER, CENTER);
* textSize(20);
*
* // Draw a flower emoji.
* text('🌸', 50, 50);
* }
* </code>
* </div>
*
* <div>
* <code>
* function setup() {
* createCanvas(100, 100);
*
* describe('A pink flower on a gray background.');
* }
*
* function draw() {
* background(200);
*
* // Call the drawFlower() function and pass values for
* // its position and size.
* drawFlower(50, 50, 20);
* }
*
* // Declare a function that draws a flower at the
* // center of the canvas.
* function drawFlower(x, y, size) {
* // Style the text.
* textAlign(CENTER, CENTER);
*
* // Use the size parameter.
* textSize(size);
*
* // Draw a flower emoji.
* // Use the x and y parameters.
* text('🌸', x, y);
* }
* </code>
* </div>
*
* <div>
* <code>
* function setup() {
* createCanvas(100, 100);
*
* describe('The message "Hello, 🌍!" written on a gray background.');
* }
*
* function draw() {
* background(200);
*
* // Create a greeting.
* let greeting = createGreeting('🌍');
*
* // Style the text.
* textAlign(CENTER, CENTER);
* textSize(16);
*
* // Display the greeting.
* text(greeting, 50, 50);
* }
*
* // Return a string with a personalized greeting.
* function createGreeting(name) {
* let message = `Hello, ${name}!`;
* return message;
* }
* </code>
* </div>
*/
/**
* A value that's either `true` or `false`.
*
* `Boolean` values help to make decisions in code. They appear any time a
* logical condition is checked. For example, the condition
* "Is a mouse button being pressed?" must be either `true` or
* `false`:
*
* ```js
* // If the user presses the mouse, draw a circle at
* // the mouse's location.
* if (mouseIsPressed === true) {
* circle(mouseX, mouseY, 20);
* }
* ```
*
* The `if` statement checks whether
* <a href="#/p5/mouseIsPressed">mouseIsPressed</a> is `true` and draws a
* circle if it is. `Boolean` expressions such as `mouseIsPressed === true`
* evaluate to one of the two possible `Boolean` values: `true` or `false`.
*
* The `===` operator (EQUAL) checks whether two values are equal. If they
* are, the expression evaluates to `true`. Otherwise, it evaluates to
* `false`.
*
* Note: There's also a `==` operator with two `=` instead of three. Don't use
* it.
*
* The <a href="#/p5/mouseIsPressed">mouseIsPressed</a> system variable is
* always `true` or `false`, so the code snippet above could also be written
* as follows:
*
* ```js
* if (mouseIsPressed) {
* circle(mouseX, mouseY, 20);
* }
* ```
*
* The `!==` operator (NOT EQUAL) checks whether two values are not equal, as
* in the following example:
*
* ```js
* if (2 + 2 !== 4) {
* text('War is peace.', 50, 50);
* }
* ```
*
* Starting from the left, the arithmetic expression `2 + 2` produces the
* value `4`. The `Boolean` expression `4 !== 4` evaluates to `false` because
* `4` is equal to itself. As a result, the `if` statement's body is skipped.
*
* Note: There's also a `!=` operator with one `=` instead of two. Don't use
* it.
*
* The `Boolean` operator `&&` (AND) checks whether two expressions are both
* `true`:
*
* ```js
* if (keyIsPressed === true && key === 'p') {
* text('You pressed the "p" key!', 50, 50);
* }
* ```
*
* If the user is pressing a key AND that key is `'p'`, then a message will
* display.
*
* The `Boolean` operator `||` (OR) checks whether at least one of two
* expressions is `true`:
*
* ```js
* if (keyIsPressed === true || mouseIsPressed === true) {
* text('You did something!', 50, 50);
* }
* ```
*
* If the user presses a key, or presses a mouse button, or both, then a
* message will display.
*
* The following truth table summarizes a few common scenarios with `&&` and
* `||`:
*
* ```js
* true && true // true
* true && false // false
* false && false // false
* true || true // true
* true || false // true
* false || false // false
* ```
*
* The relational operators `>`, `<`, `>=`, and `<=` also produce `Boolean`
* values:
*
* ```js
* 2 > 1 // true
* 2 < 1 // false
* 2 >= 2 // true
* 2 <= 2 // true
* ```
*
* See <a href="#/p5/if">if</a> for more information about `if` statements and
* <a href="#/p5/Number">Number</a> for more information about `Number`s.
*
* @property Boolean
*
* @example
* <div>
* <code>
* function setup() {
* createCanvas(100, 100);
*
* describe('A gray square. When the user presses the mouse, a circle appears at that location.');
* }
*
* function draw() {
* background(200);
*
* // If the user presses the mouse, draw a circle at that location.
* if (mouseIsPressed) {
* circle(mouseX, mouseY, 20);
* }
* }
* </code>
* </div>
*
* <div>
* <code>
* function setup() {
* createCanvas(100, 100);
*
* describe('A gray square. When the user presses the mouse, a circle appears at that location.');
* }
*
* function draw() {
* background(200);
*
* // If the user presses the mouse, draw a circle at that location.
* if (mouseIsPressed === true) {
* circle(mouseX, mouseY, 20);
* }
* }
* </code>
* </div>
*
* <div>
* <code>
* // Click on the canvas to begin detecting key presses.
*
* function setup() {
* createCanvas(100, 100);
*
* describe('A gray square that turns pink when the user presses the mouse or a key.');
* }
*
* function draw() {
* background(200);
*
* // If the user presses the mouse, change the background color.
* if (mouseIsPressed === true || keyIsPressed === true) {
* background('deeppink');
* }
* }
* </code>
* </div>
*
* <div>
* <code>
* // Click the canvas to begin detecting key presses.
*
* // Create a Boolean variable.
* let isPlaying = false;
*
* function setup() {
* createCanvas(100, 100);
*
* describe(
* 'The message "Begin?\nY or N" written in green on a black background. The message "Good luck!" appears when they press the "y" key.'
* );
* }
*
* function draw() {
* background(0);
*
* // Style the text.
* textAlign(CENTER, CENTER);
* textFont('Courier New');
* textSize(16);
* fill(0, 255, 0);
*
* // Display a different message when the user begins playing.
* if (isPlaying === false) {
* text('Begin?', 50, 40);
* text('Y or N', 50, 60);
* } else {
* text('Good luck!', 50, 50);
* }
* }
*
* // Start playing when the user presses the 'y' key.
* function keyPressed() {
* if (key === 'y') {
* isPlaying = true;
* }
* }
* </code>
* </div>
*/
/**
* A sequence of text characters.
*
* The `String` data type is helpful for working with text. For example, a
* string could contain a welcome message:
*
* ```js
* // Use a string literal.
* text('Hello!', 10, 10);
* ```
*
* ```js
* // Create a string variable.
* let message = 'Hello!';
*
* // Use the string variable.
* text(message, 10, 10);
* ```
*
* The most common way to create strings is to use some form of quotations as
* follows:
*
* ```js
* text("hi", 50, 50);
* ```
*
* ```js
* text('hi', 50, 50);
* ```
*
* ```js
* text(`hi`, 50, 50);
* ```
*
* `"hi"`, `'hi'`, and ``hi`` are all string literals. A "literal" means a
* value was actually written, as in `text('hi', 50, 50)`. By contrast,
* `text(message, 50, 50)` uses the variable `message`, so it isn't a string
* literal.
*
* Single quotes `''` and double quotes `""` mean the same thing. It's nice to
* have the option for cases when a string contains one type of quote:
*
* ```js
* text("What's up?", 50, 50);
* ```
*
* ```js
* text('Air quotes make you look "cool."', 50, 50);
* ```
*
* Backticks ` `` ` create template literals. Template literals have many uses.
* For example, they can contain both single and double quotes as needed:
*
* ```js
* text(`"Don't you forget about me"`, 10, 10);
* ```
*
* Template literals are helpful when strings are created from variables like
* so:
*
* ```js
* let size = random(10, 20);
* circle(50, 50, size);
*
* text(`The circle's diameter is ${size} pixels.`, 10, 10);
* ```
*
* The `size` variable's value will replace `${size}` when the string is
* created. `${}` is a placeholder for any value. That means an expression can
* be used, as in `${round(PI, 3)}`. All of the following are valid template
* literals:
*
* ```js
* text(`π is about ${round(PI, 2)} pixels.`, 10, 10);
* text(`It's ${mouseX < width / 2} that I'm on the left half of the canvas.`, 10, 30);
* ```
*
* Template literals can include several variables:
*
* ```js
* let x = random(0, 100);
* let y = random(0, 100);
* let size = random(10, 20);
* circle(x, y, size);
*
* text(`The circle at (${x}, ${y}) has a diameter of ${size} pixels.`, 10, 10);
* ```
*
* Template literals are also helpful for creating multi-line text like so:
*
* ```js
* let poem = `My sketch doesn't run;
* it waits for me patiently
* while bugs point the way.`;
*
* text(poem, 10, 10);
* ```
*
* @property String
*
* @example
* <div>
* <code>
* function setup() {
* createCanvas(100, 100);
*
* background(200);
*
* // Style the text.
* textAlign(CENTER, CENTER);
* textSize(20);
*
* // Display a welcome message.
* text('Hello!', 50, 50);
*
* describe('The text "Hello!" written on a gray background.');
* }
* </code>
* </div>
*
* <div>
* <code>
* function setup() {
* createCanvas(100, 100);
*
* background(200);
*
* // Style the text.
* textAlign(CENTER, CENTER);
* textSize(20);
*
* // Create a string variable.
* let world = '🌍';
*
* // Display a welcome message using a template string.
* text(`Hello, ${world}!`, 50, 50);
*
* describe('The text "Hello, 🌍!" written on a gray background.');
* }
* </code>
* </div>
*/
/**
* A number that can be positive, negative, or zero.
*
* The `Number` data type is useful for describing values such as position,
* size, and color. A number can be an integer such as 20 or a decimal number
* such as 12.34. For example, a circle's position and size can be described
* by three numbers:
*
* ```js
* circle(50, 50, 20);
* ```
*
* ```js
* circle(50, 50, 12.34);
* ```
*
* Numbers support basic arithmetic and follow the standard order of
* operations: Parentheses, Exponents, Multiplication, Division, Addition,
* and Subtraction (PEMDAS). For example, it's common to use arithmetic
* operators with p5.js' system variables that are numbers:
*
* ```js
* // Draw a circle at the center.
* circle(width / 2, height / 2, 20);
* ```
*
* ```js
* // Draw a circle that moves from left to right.
* circle(frameCount * 0.01, 50, 20);
* ```
*
* Here's a quick overview of the arithmetic operators:
*
* ```js
* 1 + 2 // Add
* 1 - 2 // Subtract
* 1 * 2 // Multiply
* 1 / 2 // Divide
* 1 % 2 // Remainder
* 1 ** 2 // Exponentiate
* ```
*
* It's common to update a number variable using arithmetic. For example, an
* object's location can be updated like so:
*
* ```js
* x = x + 1;
* ```
*
* The statement above adds 1 to a variable `x` using the `+` operator. The
* addition assignment operator `+=` expresses the same idea:
*
* ```js
* x += 1;
* ```
*
* Here's a quick overview of the assignment operators:
*
* ```js
* x += 2 // Addition assignment
* x -= 2 // Subtraction assignment
* x *= 2 // Multiplication assignment
* x /= 2 // Division assignment
* x %= 2 // Remainder assignment
* ```
*
* Numbers can be compared using the
* <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators#relational_operators" target="_blank">relational operators</a>
* `>`, `<`, `>=`, `<=`, `===`, and `!==`. For example, a sketch's
* <a href="#/p5/frameCount">frameCount</a> can be used as a timer:
*
* ```js
* if (frameCount > 1000) {
* text('Game over!', 50, 50);
* }
* ```
*
* An expression such as `frameCount > 1000` evaluates to a `Boolean` value
* that's either `true` or `false`. The relational operators all produce
* `Boolean` values:
*
* ```js
* 2 > 1 // true
* 2 < 1 // false
* 2 >= 2 // true
* 2 <= 2 // true
* 2 === 2 // true
* 2 !== 2 // false
* ```
*
* See <a href="#/p5/Boolean">Boolean</a> for more information about comparisons and conditions.
*
* Note: There are also `==` and `!=` operators with one fewer `=`. Don't use them.
*
* Expressions with numbers can also produce special values when something
* goes wrong:
*
* ```js
* sqrt(-1) // NaN
* 1 / 0 // Infinity
* ```
*
* The value `NaN` stands for
* <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN" target="_blank">Not-A-Number</a>.
* `NaN` appears when calculations or conversions don't work. `Infinity` is a
* value that's larger than any number. It appears during certain
* calculations.
*
* @property Number
*
* @example
* <div>
* <code>
* function setup() {
* createCanvas(100, 100);
*
* background(200);
*
* // Draw a circle at the center.
* circle(50, 50, 70);
*
* // Draw a smaller circle at the center.
* circle(width / 2, height / 2, 30);
*
* describe('Two concentric, white circles drawn on a gray background.');
* }
* </code>
* </div>
*
* <div>
* <code>
* function setup() {
* createCanvas(100, 100);
*
* describe('A white circle travels from left to right on a gray background.');
* }
*
* function draw() {
* background(200);
*
* circle(frameCount * 0.05, 50, 20);
* }
* </code>
* </div>
*/
/**
* A container for data that's stored as key-value pairs.