Skip to content

Commit f57bd77

Browse files
committed
use let/const in all examples
1 parent 49bf914 commit f57bd77

File tree

12 files changed

+94
-94
lines changed

12 files changed

+94
-94
lines changed

src/core/error_helpers.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ if (typeof IS_MINIFIED !== 'undefined') {
4848

4949
const friendlyWelcome = () => {
5050
// p5.js brand - magenta: #ED225D
51-
//var astrixBgColor = 'transparent';
52-
//var astrixTxtColor = '#ED225D';
53-
//var welcomeBgColor = '#ED225D';
54-
//var welcomeTextColor = 'white';
51+
//const astrixBgColor = 'transparent';
52+
//const astrixTxtColor = '#ED225D';
53+
//const welcomeBgColor = '#ED225D';
54+
//const welcomeTextColor = 'white';
5555
console.log(
5656
' _ \n' +
5757
' /\\| |/\\ \n' +
@@ -565,7 +565,7 @@ if (typeof IS_MINIFIED !== 'undefined') {
565565
* param {Array} args user input arguments
566566
*
567567
* example:
568-
* var a;
568+
* const a;
569569
* ellipse(10,10,a,5);
570570
* console ouput:
571571
* "It looks like ellipse received an empty variable in spot #2."
@@ -625,7 +625,7 @@ if (typeof IS_MINIFIED !== 'undefined') {
625625
* For color blindness testing.
626626
*/
627627
/* function testColors() {
628-
var str = 'A box of biscuits, a box of mixed biscuits and a biscuit mixer';
628+
const str = 'A box of biscuits, a box of mixed biscuits and a biscuit mixer';
629629
report(str, 'print', '#ED225D'); // p5.js magenta
630630
report(str, 'print', '#2D7BB6'); // p5.js blue
631631
report(str, 'print', '#EE9900'); // p5.js orange

src/core/p5.Renderer2D.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import './p5.Renderer';
1010
* extends p5.Renderer
1111
*/
1212
const styleEmpty = 'rgba(0,0,0,0)';
13-
// var alphaThreshold = 0.00125; // minimum visible
13+
// const alphaThreshold = 0.00125; // minimum visible
1414

1515
p5.Renderer2D = function(elt, pInst, isMainCanvas) {
1616
p5.Renderer.call(this, elt, pInst, isMainCanvas);

src/core/shape/vertex.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,13 +916,13 @@ p5.prototype.quadraticVertex = function(...args) {
916916
*
917917
* function ngon(n, x, y, d) {
918918
* beginShape();
919-
* for (var i = 0; i < n + 1; i++) {
919+
* for (let i = 0; i < n + 1; i++) {
920920
* angle = TWO_PI / n * i;
921921
* px = x + sin(angle) * d / 2;
922922
* py = y - cos(angle) * d / 2;
923923
* vertex(px, py, 0);
924924
* }
925-
* for (i = 0; i < n + 1; i++) {
925+
* for (let i = 0; i < n + 1; i++) {
926926
* angle = TWO_PI / n * i;
927927
* px = x + sin(angle) * d / 4;
928928
* py = y - cos(angle) * d / 4;

src/core/transform.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import p5 from './main';
4141
* }
4242
*
4343
* function draw() {
44-
* var step = frameCount % 20;
44+
* let step = frameCount % 20;
4545
* background(200);
4646
* // Equivalent to translate(x, y);
4747
* applyMatrix(1, 0, 0, 1, 40 + step, 50);
@@ -57,7 +57,7 @@ import p5 from './main';
5757
* }
5858
*
5959
* function draw() {
60-
* var step = frameCount % 20;
60+
* let step = frameCount % 20;
6161
* background(200);
6262
* translate(50, 50);
6363
* // Equivalent to scale(x, y);
@@ -74,10 +74,10 @@ import p5 from './main';
7474
* }
7575
*
7676
* function draw() {
77-
* var step = frameCount % 20;
78-
* var angle = map(step, 0, 20, 0, TWO_PI);
79-
* var cos_a = cos(angle);
80-
* var sin_a = sin(angle);
77+
* let step = frameCount % 20;
78+
* let angle = map(step, 0, 20, 0, TWO_PI);
79+
* let cos_a = cos(angle);
80+
* let sin_a = sin(angle);
8181
* background(200);
8282
* translate(50, 50);
8383
* // Equivalent to rotate(angle);
@@ -94,12 +94,12 @@ import p5 from './main';
9494
* }
9595
*
9696
* function draw() {
97-
* var step = frameCount % 20;
98-
* var angle = map(step, 0, 20, -PI / 4, PI / 4);
97+
* let step = frameCount % 20;
98+
* let angle = map(step, 0, 20, -PI / 4, PI / 4);
9999
* background(200);
100100
* translate(50, 50);
101101
* // equivalent to shearX(angle);
102-
* var shear_factor = 1 / tan(PI / 2 - angle);
102+
* let shear_factor = 1 / tan(PI / 2 - angle);
103103
* applyMatrix(1, 0, shear_factor, 1, 0, 0);
104104
* rect(0, 0, 50, 50);
105105
* }
@@ -117,10 +117,10 @@ import p5 from './main';
117117
* rotateY(PI / 6);
118118
* stroke(153);
119119
* box(35);
120-
* var rad = millis() / 1000;
120+
* let rad = millis() / 1000;
121121
* // Set rotation angles
122-
* var ct = cos(rad);
123-
* var st = sin(rad);
122+
* let ct = cos(rad);
123+
* let st = sin(rad);
124124
* // Matrix for rotation around the Y axis
125125
* // prettier-ignore
126126
* applyMatrix( ct, 0.0, st, 0.0,

src/events/acceleration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ p5.prototype._updatePRotations = function() {
388388
* // Rotate the device by 90 degrees in the
389389
* // X-axis to change the value.
390390
*
391-
* var value = 0;
391+
* let value = 0;
392392
* function draw() {
393393
* fill(value);
394394
* rect(25, 25, 50, 50);

src/io/files.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ p5.prototype._pWriters = [];
12051205
*
12061206
* function mousePressed() {
12071207
* if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {
1208-
* var writer = createWriter('squares.txt');
1208+
* const writer = createWriter('squares.txt');
12091209
* for (let i = 0; i < 10; i++) {
12101210
* writer.print(i * i);
12111211
* }

src/utilities/array_functions.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import p5 from '../core/main';
1919
* @example
2020
* <div class='norender'><code>
2121
* function setup() {
22-
* var myArray = ['Mango', 'Apple', 'Papaya'];
22+
* const myArray = ['Mango', 'Apple', 'Papaya'];
2323
* print(myArray); // ['Mango', 'Apple', 'Papaya']
2424
*
2525
* append(myArray, 'Peach');
@@ -57,11 +57,11 @@ p5.prototype.append = (array, value) => {
5757
*
5858
* @example
5959
* <div class='norender'><code>
60-
* var src = ['A', 'B', 'C'];
61-
* var dst = [1, 2, 3];
62-
* var srcPosition = 1;
63-
* var dstPosition = 0;
64-
* var length = 2;
60+
* let src = ['A', 'B', 'C'];
61+
* let dst = [1, 2, 3];
62+
* let srcPosition = 1;
63+
* let dstPosition = 0;
64+
* let length = 2;
6565
*
6666
* print(src); // ['A', 'B', 'C']
6767
* print(dst); // [ 1 , 2 , 3 ]
@@ -122,13 +122,13 @@ p5.prototype.arrayCopy = (src, srcPosition, dst, dstPosition, length) => {
122122
* @example
123123
* <div class = 'norender'><code>
124124
* function setup() {
125-
* var arr1 = ['A', 'B', 'C'];
126-
* var arr2 = [1, 2, 3];
125+
* let arr1 = ['A', 'B', 'C'];
126+
* let arr2 = [1, 2, 3];
127127
*
128128
* print(arr1); // ['A','B','C']
129129
* print(arr2); // [1,2,3]
130130
*
131-
* var arr3 = concat(arr1, arr2);
131+
* let arr3 = concat(arr1, arr2);
132132
*
133133
* print(arr1); // ['A','B','C']
134134
* print(arr2); // [1, 2, 3]
@@ -148,7 +148,7 @@ p5.prototype.concat = (list0, list1) => list0.concat(list1);
148148
* @example
149149
* <div class='norender'><code>
150150
* function setup() {
151-
* var myArray = ['A', 'B', 'C'];
151+
* let myArray = ['A', 'B', 'C'];
152152
* print(myArray); // ['A','B','C']
153153
*
154154
* reverse(myArray);
@@ -169,9 +169,9 @@ p5.prototype.reverse = list => list.reverse();
169169
* @example
170170
* <div class = 'norender'><code>
171171
* function setup() {
172-
* var myArray = ['A', 'B', 'C'];
172+
* let myArray = ['A', 'B', 'C'];
173173
* print(myArray); // ['A', 'B', 'C']
174-
* var newArray = shorten(myArray);
174+
* let newArray = shorten(myArray);
175175
* print(myArray); // ['A','B','C']
176176
* print(newArray); // ['A','B']
177177
* }
@@ -194,13 +194,13 @@ p5.prototype.shorten = list => {
194194
* @example
195195
* <div><code>
196196
* function setup() {
197-
* var regularArr = ['ABC', 'def', createVector(), TAU, Math.E];
197+
* let regularArr = ['ABC', 'def', createVector(), TAU, Math.E];
198198
* print(regularArr);
199199
* shuffle(regularArr, true); // force modifications to passed array
200200
* print(regularArr);
201201
*
202202
* // By default shuffle() returns a shuffled cloned array:
203-
* var newArr = shuffle(regularArr);
203+
* let newArr = shuffle(regularArr);
204204
* print(regularArr);
205205
* print(newArr);
206206
* }
@@ -240,19 +240,19 @@ p5.prototype.shuffle = (arr, bool) => {
240240
* @example
241241
* <div class = 'norender'><code>
242242
* function setup() {
243-
* var words = ['banana', 'apple', 'pear', 'lime'];
243+
* let words = ['banana', 'apple', 'pear', 'lime'];
244244
* print(words); // ['banana', 'apple', 'pear', 'lime']
245-
* var count = 4; // length of array
245+
* let count = 4; // length of array
246246
*
247247
* words = sort(words, count);
248248
* print(words); // ['apple', 'banana', 'lime', 'pear']
249249
* }
250250
* </code></div>
251251
* <div class = 'norender'><code>
252252
* function setup() {
253-
* var numbers = [2, 6, 1, 5, 14, 9, 8, 12];
253+
* let numbers = [2, 6, 1, 5, 14, 9, 8, 12];
254254
* print(numbers); // [2, 6, 1, 5, 14, 9, 8, 12]
255-
* var count = 5; // Less than the length of the array
255+
* let count = 5; // Less than the length of the array
256256
*
257257
* numbers = sort(numbers, count);
258258
* print(numbers); // [1,2,5,6,14,9,8,12]
@@ -288,8 +288,8 @@ p5.prototype.sort = (list, count) => {
288288
* @example
289289
* <div class = 'norender'><code>
290290
* function setup() {
291-
* var myArray = [0, 1, 2, 3, 4];
292-
* var insArray = ['A', 'B', 'C'];
291+
* let myArray = [0, 1, 2, 3, 4];
292+
* let insArray = ['A', 'B', 'C'];
293293
* print(myArray); // [0, 1, 2, 3, 4]
294294
* print(insArray); // ['A','B','C']
295295
*
@@ -323,11 +323,11 @@ p5.prototype.splice = (list, value, index) => {
323323
* @example
324324
* <div class = 'norender'><code>
325325
* function setup() {
326-
* var myArray = [1, 2, 3, 4, 5];
326+
* let myArray = [1, 2, 3, 4, 5];
327327
* print(myArray); // [1, 2, 3, 4, 5]
328328
*
329-
* var sub1 = subset(myArray, 0, 3);
330-
* var sub2 = subset(myArray, 2, 2);
329+
* let sub1 = subset(myArray, 0, 3);
330+
* let sub2 = subset(myArray, 2, 2);
331331
* print(sub1); // [1,2,3]
332332
* print(sub2); // [3,4]
333333
* }

src/utilities/conversion.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import p5 from '../core/main';
2121
* @return {Number} floating point representation of string
2222
* @example
2323
* <div><code>
24-
* var str = '20';
25-
* var diameter = float(str);
24+
* let str = '20';
25+
* let diameter = float(str);
2626
* ellipse(width / 2, height / 2, diameter, diameter);
2727
* </code></div>
2828
* <div class='norender'><code>

0 commit comments

Comments
 (0)