Skip to content

Commit 90e2c43

Browse files
committed
Introduce + enforce code style rules
1 parent bcdcda2 commit 90e2c43

File tree

106 files changed

+14974
-14981
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+14974
-14981
lines changed

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
libraries/*
2+
styles/*
3+
p5.js
4+
*.min.js

.eslintrc

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"env": {
3+
"browser": true
4+
},
5+
"rules": {
6+
"semi": "error",
7+
"no-eval": "error",
8+
"indent": [
9+
"error",
10+
2
11+
],
12+
"quotes": [
13+
"error",
14+
"single"
15+
],
16+
"no-multiple-empty-lines": [
17+
"error",
18+
{
19+
"max": 1,
20+
"maxEOF": 1,
21+
"maxBOF": 0
22+
}
23+
],
24+
"no-mixed-spaces-and-tabs": "error",
25+
"no-tabs": "error",
26+
"no-trailing-spaces": "error",
27+
"semi-style": [
28+
"error",
29+
"last"
30+
],
31+
"spaced-comment": "error",
32+
"switch-colon-spacing": [
33+
"error",
34+
{
35+
"after": true,
36+
"before": false
37+
}
38+
],
39+
"space-infix-ops": "error",
40+
"no-multi-spaces": "error",
41+
"space-in-parens": [
42+
"error",
43+
"never"
44+
],
45+
"space-unary-ops": "error",
46+
"brace-style": "error",
47+
"eol-last": "error",
48+
"comma-dangle": [
49+
"error",
50+
"always"
51+
],
52+
"func-call-spacing": "error",
53+
"key-spacing": "error",
54+
"keyword-spacing": "error"
55+
}
56+
}

01_P/P_1_2_1_01/sketch.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
var tileCountX = 2;
3636
var tileCountY = 10;
3737

38-
var colorsLeft = []
38+
var colorsLeft = [];
3939
var colorsRight = [];
4040
var colors = [];
4141

@@ -97,7 +97,7 @@ function mouseReleased() {
9797
}
9898

9999
function keyPressed() {
100-
if (key == 'c' || key == 'C') writeFile([gd.ase.encode( colors )], gd.timestamp(), 'ase');
100+
if (key == 'c' || key == 'C') writeFile([gd.ase.encode(colors),], gd.timestamp(), 'ase');
101101
if (key == 's' || key == 'S') saveCanvas(gd.timestamp(), 'png');
102102
if (key == '1') interpolateShortest = true;
103103
if (key == '2') interpolateShortest = false;

01_P/P_1_2_2_01/sketch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function draw() {
7979
}
8080

8181
function keyReleased() {
82-
if (key == 'c' || key == 'C') writeFile([gd.ase.encode(colors)], gd.timestamp(), 'ase');
82+
if (key == 'c' || key == 'C') writeFile([gd.ase.encode(colors),], gd.timestamp(), 'ase');
8383
if (key == 's' || key == 'S') saveCanvas(gd.timestamp(), 'png');
8484

8585
if (key == '1') loadImage('data/pic1.jpg', setImage);

01_P/P_1_2_3_01/sketch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function keyPressed() {
8989
for (var i = 0; i < hueValues.length; i++) {
9090
colors.push(color(hueValues[i], saturationValues[i], brightnessValues[i]));
9191
}
92-
writeFile([gd.ase.encode(colors)], gd.timestamp(), 'ase');
92+
writeFile([gd.ase.encode(colors),], gd.timestamp(), 'ase');
9393
}
9494

9595
if (key == '1') {

01_P/P_1_2_3_02/sketch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,6 @@ function keyPressed() {
125125
for (var i = 0; i < hueValues.length; i++) {
126126
colors.push(color(hueValues[i], saturationValues[i], brightnessValues[i]));
127127
}
128-
writeFile([gd.ase.encode(colors)], gd.timestamp(), 'ase');
128+
writeFile([gd.ase.encode(colors),], gd.timestamp(), 'ase');
129129
}
130130
}

01_P/P_1_2_3_03/sketch.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ function gradient(x, y, w, h, c1, c2) {
119119
var grd = ctx.createLinearGradient(x, y, x, y + h);
120120
grd.addColorStop(0, c1.toString());
121121
grd.addColorStop(1, c2.toString());
122-
ctx.fillStyle = grd;
123-
ctx.fillRect(x, y, w, h);
122+
ctx.fillStyle = grd;
123+
ctx.fillRect(x, y, w, h);
124124
}
125125

126126
function mouseReleased() {
@@ -136,6 +136,6 @@ function keyPressed() {
136136
for (var i = 0; i < hueValues.length; i++) {
137137
colors.push(color(hueValues[i], saturationValues[i], brightnessValues[i]));
138138
}
139-
writeFile([gd.ase.encode(colors)], gd.timestamp(), 'ase');
139+
writeFile([gd.ase.encode(colors),], gd.timestamp(), 'ase');
140140
}
141141
}

01_P/P_1_2_3_04/sketch.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ function gradient(x, y, w, h, c1, c2) {
121121
var grd = ctx.createLinearGradient(x, y, x, y + h);
122122
grd.addColorStop(0, c1.toString());
123123
grd.addColorStop(1, c2.toString());
124-
ctx.fillStyle = grd;
125-
ctx.fillRect(x, y, w, h);
124+
ctx.fillStyle = grd;
125+
ctx.fillRect(x, y, w, h);
126126
}
127127

128128
function mouseReleased() {
@@ -138,6 +138,6 @@ function keyPressed() {
138138
for (var i = 0; i < hueValues.length; i++) {
139139
colors.push(color(hueValues[i], saturationValues[i], brightnessValues[i]));
140140
}
141-
writeFile([gd.ase.encode(colors)], gd.timestamp(), 'ase');
141+
writeFile([gd.ase.encode(colors),], gd.timestamp(), 'ase');
142142
}
143143
}

01_P/P_1_2_3_05/sketch.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function draw() {
101101

102102
if (random() < 0.45) {
103103
var w = map(parts[ii], 0, sumPartsTotal, 0, width);
104-
var h = rowHeight * 1.5
104+
var h = rowHeight * 1.5;
105105
var px1 = map(sumPartsNow, 0, sumPartsTotal, 0, width);
106106
var px2 = px1 + w;
107107
var py1 = rowHeight * i;
@@ -126,8 +126,8 @@ function centerGradient(x1, y1, r1, x2, y2, r2, c1, c2) {
126126
var grd = ctx.createRadialGradient(cx, cy, r1, cx, cy, r2);
127127
grd.addColorStop(0, c1.toString());
128128
grd.addColorStop(1, c2.toString());
129-
ctx.fillStyle = grd;
130-
ctx.fillRect(x1, y1, x2 - x1, y2 - y1);
129+
ctx.fillStyle = grd;
130+
ctx.fillRect(x1, y1, x2 - x1, y2 - y1);
131131
}
132132

133133
function mouseReleased() {
@@ -143,6 +143,6 @@ function keyPressed() {
143143
for (var i = 0; i < hueValues.length; i++) {
144144
colors.push(color(hueValues[i], saturationValues[i], brightnessValues[i]));
145145
}
146-
writeFile([gd.ase.encode(colors)], gd.timestamp(), 'ase');
146+
writeFile([gd.ase.encode(colors),], gd.timestamp(), 'ase');
147147
}
148148
}

01_P/P_2_1_1_04/sketch.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ var sizeMode = 0;
4848

4949
function preload() {
5050
shapes = [];
51-
shapes.push(loadImage("data/module_1.svg"));
52-
shapes.push(loadImage("data/module_2.svg"));
53-
shapes.push(loadImage("data/module_3.svg"));
54-
shapes.push(loadImage("data/module_4.svg"));
55-
shapes.push(loadImage("data/module_5.svg"));
56-
shapes.push(loadImage("data/module_6.svg"));
57-
shapes.push(loadImage("data/module_7.svg"));
51+
shapes.push(loadImage('data/module_1.svg'));
52+
shapes.push(loadImage('data/module_2.svg'));
53+
shapes.push(loadImage('data/module_3.svg'));
54+
shapes.push(loadImage('data/module_4.svg'));
55+
shapes.push(loadImage('data/module_5.svg'));
56+
shapes.push(loadImage('data/module_6.svg'));
57+
shapes.push(loadImage('data/module_7.svg'));
5858
}
5959

6060
function setup() {

0 commit comments

Comments
 (0)