Skip to content

Commit 1458dd9

Browse files
All other var to let
Changed var to let in the es and en directories.
1 parent 5b0becd commit 1458dd9

36 files changed

+194
-194
lines changed

src/data/examples/en/08_Math/00_incrementdecrement.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
* @description Writing "a++" is equivalent to "a = a + 1".
44
* Writing "a--" is equivalent to "a = a - 1".
55
*/
6-
var a;
7-
var b;
8-
var direction;
6+
let a;
7+
let b;
8+
let direction;
99

1010
function setup() {
1111
createCanvas(710, 400);

src/data/examples/en/08_Math/01_operatorprecedence.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function setup() {
2626
stroke(51);
2727

2828
stroke(204);
29-
for(var i=0; i< width-20; i+= 4) {
29+
for(let i=0; i< width-20; i+= 4) {
3030
// The 30 is added to 70 and then evaluated
3131
// if it is greater than the current value of "i"
3232
// For clarity, write as "if (i > (30 + 70)) {"
@@ -42,7 +42,7 @@ function setup() {
4242
rect((4 + 2) * 8, 100, 290, 49);
4343

4444
stroke(153);
45-
for (var i = 0; i < width; i+= 2) {
45+
for (let i = 0; i < width; i+= 2) {
4646
// The relational statements are evaluated
4747
// first, and then the logical AND statements and
4848
// finally the logical OR. For clarity, write as:

src/data/examples/en/08_Math/02_distance1d.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
* @description Move the mouse left and right to control
44
* the speed and direction of the moving shapes.
55
*/
6-
var xpos1;
7-
var xpos2;
8-
var xpos3;
9-
var xpos4;
10-
var thin = 8;
11-
var thick = 36;
6+
let xpos1;
7+
let xpos2;
8+
let xpos3;
9+
let xpos4;
10+
let thin = 8;
11+
let thick = 36;
1212

1313
function setup() {
1414
createCanvas(710, 400);
@@ -22,7 +22,7 @@ function setup() {
2222
function draw() {
2323
background(0);
2424

25-
var mx = mouseX * 0.4 - width/5.0;
25+
let mx = mouseX * 0.4 - width/5.0;
2626

2727
fill(102);
2828
rect(xpos2, 0, thick, height/2);

src/data/examples/en/08_Math/03_distance2d.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* and reveal the matrix. Measures the distance from the mouse
55
* to each square and sets the size proportionally.
66
*/
7-
var max_distance;
7+
let max_distance;
88

99
function setup() {
1010
createCanvas(710, 400);
@@ -15,9 +15,9 @@ function setup() {
1515
function draw() {
1616
background(0);
1717

18-
for(var i = 0; i <= width; i += 20) {
19-
for(var j = 0; j <= height; j += 20) {
20-
var size = dist(mouseX, mouseY, i, j);
18+
for(let i = 0; i <= width; i += 20) {
19+
for(let j = 0; j <= height; j += 20) {
20+
let size = dist(mouseX, mouseY, i, j);
2121
size = size/max_distance * 66;
2222
ellipse(i, j, size, size);
2323
}

src/data/examples/en/08_Math/04_sine.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* @name Sine
33
* @description Smoothly scaling size with the sin() function.
44
*/
5-
var diameter;
6-
var angle = 0;
5+
let diameter;
6+
let angle = 0;
77

88
function setup() {
99
createCanvas(710, 400);
@@ -15,9 +15,9 @@ function setup() {
1515
function draw() {
1616
background(0);
1717

18-
var d1 = 10 + (sin(angle) * diameter/2) + diameter/2;
19-
var d2 = 10 + (sin(angle + PI/2) * diameter/2) + diameter/2;
20-
var d3 = 10 + (sin(angle + PI) * diameter/2) + diameter/2;
18+
let d1 = 10 + (sin(angle) * diameter/2) + diameter/2;
19+
let d2 = 10 + (sin(angle + PI/2) * diameter/2) + diameter/2;
20+
let d3 = 10 + (sin(angle + PI) * diameter/2) + diameter/2;
2121

2222
ellipse(0, height/2, d1, d1);
2323
ellipse(width/2, height/2, d2, d2);

src/data/examples/en/08_Math/05_sincosine.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
* are put into these functions and numbers between -1 and 1 are returned.
66
* These values are then scaled to produce larger movements.
77
*/
8-
var angle1=0;
9-
var angle2=0;
10-
var scalar = 70;
8+
let angle1=0;
9+
let angle2=0;
10+
let scalar = 70;
1111

1212
function setup() {
1313
createCanvas(710, 400);
@@ -18,14 +18,14 @@ function setup() {
1818
function draw() {
1919
background(0);
2020

21-
var ang1 = radians(angle1);
22-
var ang2 = radians(angle2);
21+
let ang1 = radians(angle1);
22+
let ang2 = radians(angle2);
2323

24-
var x1 = width/2 + (scalar * cos(ang1));
25-
var x2 = width/2 + (scalar * cos(ang2));
24+
let x1 = width/2 + (scalar * cos(ang1));
25+
let x2 = width/2 + (scalar * cos(ang2));
2626

27-
var y1 = height/2 + (scalar * sin(ang1));
28-
var y2 = height/2 + (scalar * sin(ang2));
27+
let y1 = height/2 + (scalar * sin(ang1));
28+
let y2 = height/2 + (scalar * sin(ang2));
2929

3030
fill(255);
3131
rect(width*0.5, height*0.5, 140, 140);

src/data/examples/en/08_Math/06_sinewave.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
* Original by Daniel Shiffman.
55
*/
66

7-
var xspacing = 16; // Distance between each horizontal location
8-
var w; // Width of entire wave
9-
var theta = 0.0; // Start angle at 0
10-
var amplitude = 75.0; // Height of wave
11-
var period = 500.0; // How many pixels before the wave repeats
12-
var dx; // Value for incrementing x
13-
var yvalues; // Using an array to store height values for the wave
7+
let xspacing = 16; // Distance between each horizontal location
8+
let w; // Width of entire wave
9+
let theta = 0.0; // Start angle at 0
10+
let amplitude = 75.0; // Height of wave
11+
let period = 500.0; // How many pixels before the wave repeats
12+
let dx; // Value for incrementing x
13+
let yvalues; // Using an array to store height values for the wave
1414

1515
function setup() {
1616
createCanvas(710, 400);
@@ -31,8 +31,8 @@ function calcWave() {
3131
theta += 0.02;
3232

3333
// For every x value, calculate a y value with sine function
34-
var x = theta;
35-
for (var i = 0; i < yvalues.length; i++) {
34+
let x = theta;
35+
for (let i = 0; i < yvalues.length; i++) {
3636
yvalues[i] = sin(x)*amplitude;
3737
x+=dx;
3838
}
@@ -42,7 +42,7 @@ function renderWave() {
4242
noStroke();
4343
fill(255);
4444
// A simple way to draw the wave with an ellipse at each location
45-
for (var x = 0; x < yvalues.length; x++) {
45+
for (let x = 0; x < yvalues.length; x++) {
4646
ellipse(x*xspacing, height/2+yvalues[x], 16, 16);
4747
}
4848
}

src/data/examples/en/08_Math/07_additivewave.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@
33
* @description Create a more complex wave by adding two waves together.
44
* Original by Daniel Shiffman
55
*/
6-
var xspacing = 8; // Distance between each horizontal location
7-
var w; // Width of entire wave
8-
var maxwaves = 4; // total # of waves to add together
6+
let xspacing = 8; // Distance between each horizontal location
7+
let w; // Width of entire wave
8+
let maxwaves = 4; // total # of waves to add together
99

10-
var theta = 0.0;
11-
var amplitude = new Array(maxwaves); // Height of wave
10+
let theta = 0.0;
11+
let amplitude = new Array(maxwaves); // Height of wave
1212
// Value for incrementing X, to be calculated
1313
// as a function of period and xspacing
14-
var dx = new Array(maxwaves);
14+
let dx = new Array(maxwaves);
1515
// Using an array to store height values
1616
// for the wave (not entirely necessary)
17-
var yvalues;
17+
let yvalues;
1818

1919
function setup() {
2020
createCanvas(710, 400);
2121
frameRate(30);
2222
colorMode(RGB, 255, 255, 255, 100);
2323
w = width + 16;
2424

25-
for (var i = 0; i < maxwaves; i++) {
25+
for (let i = 0; i < maxwaves; i++) {
2626
amplitude[i] = random(10,30);
27-
var period = random(100,300); // Num pixels before wave repeats
27+
let period = random(100,300); // Num pixels before wave repeats
2828
dx[i] = (TWO_PI / period) * xspacing;
2929
}
3030

@@ -43,14 +43,14 @@ function calcWave() {
4343
theta += 0.02;
4444

4545
// Set all height values to zero
46-
for (var i = 0; i < yvalues.length; i++) {
46+
for (let i = 0; i < yvalues.length; i++) {
4747
yvalues[i] = 0;
4848
}
4949

5050
// Accumulate wave height values
51-
for (var j = 0; j < maxwaves; j++) {
52-
var x = theta;
53-
for (var i = 0; i < yvalues.length; i++) {
51+
for (let j = 0; j < maxwaves; j++) {
52+
let x = theta;
53+
for (let i = 0; i < yvalues.length; i++) {
5454
// Every other wave is cosine instead of sine
5555
if (j % 2 == 0) yvalues[i] += sin(x)*amplitude[j];
5656
else yvalues[i] += cos(x)*amplitude[j];
@@ -64,7 +64,7 @@ function renderWave() {
6464
noStroke();
6565
fill(255,50);
6666
ellipseMode(CENTER);
67-
for (var x = 0; x < yvalues.length; x++) {
67+
for (let x = 0; x < yvalues.length; x++) {
6868
ellipse(x*xspacing,width/2+yvalues[x],16,16);
6969
}
7070
}

src/data/examples/en/08_Math/08_polartocartesian.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
* to cartesian (x,y): x = rcos(theta) y = rsin(theta)
55
* Original by Daniel Shiffman.
66
*/
7-
var r;
7+
let r;
88

99
// Angle and angular velocity, accleration
10-
var theta;
11-
var theta_vel;
12-
var theta_acc;
10+
let theta;
11+
let theta_vel;
12+
let theta_acc;
1313

1414
function setup() {
1515
createCanvas(710, 400);
@@ -29,8 +29,8 @@ function draw() {
2929
translate(width/2, height/2);
3030

3131
// Convert polar to cartesian
32-
var x = r * cos(theta);
33-
var y = r * sin(theta);
32+
let x = r * cos(theta);
33+
let y = r * sin(theta);
3434

3535
// Draw the ellipse at the cartesian coordinate
3636
ellipseMode(CENTER);

src/data/examples/en/08_Math/09_arctangent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @name Arctangent
33
* @description Move the mouse to change the direction of the eyes.<br>The atan2() function computes the angle from each eye to the cursor.
44
*/
5-
var e1, e2, e3;
5+
let e1, e2, e3;
66

77
function setup() {
88
createCanvas(720, 400);

0 commit comments

Comments
 (0)