Skip to content

Commit 2be5a94

Browse files
committed
Clean up code indentation
1 parent f84b7eb commit 2be5a94

10 files changed

+558
-558
lines changed

actionPotential.js

+41-41
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
11
'use strict';
22

33
class ActionPotential {
4-
constructor(sourceNeuron, destinyNeuron, skew, id, charge, neuronSize) {
5-
this.sourceNeuron = sourceNeuron;
6-
this.destinyNeuron = destinyNeuron;
4+
constructor(sourceNeuron, destinyNeuron, skew, id, charge, neuronSize) {
5+
this.sourceNeuron = sourceNeuron;
6+
this.destinyNeuron = destinyNeuron;
77

8-
this.size = neuronSize/5;
9-
this.id = id;
10-
this.charge = charge;
8+
this.size = neuronSize/5;
9+
this.id = id;
10+
this.charge = charge;
1111

12-
skew -= this.size/2;
13-
this.xCoord = sourceNeuron.xCoord + skew;
14-
this.yCoord = sourceNeuron.yCoord + skew;
15-
this.destinyX = destinyNeuron.xCoord + skew;
16-
this.destinyY = destinyNeuron.yCoord + skew;
12+
skew -= this.size/2;
13+
this.xCoord = sourceNeuron.xCoord + skew;
14+
this.yCoord = sourceNeuron.yCoord + skew;
15+
this.destinyX = destinyNeuron.xCoord + skew;
16+
this.destinyY = destinyNeuron.yCoord + skew;
1717

1818
let length = Math.sqrt(Math.pow(this.destinyX-this.xCoord, 2) + Math.pow(this.destinyY-this.yCoord, 2));
1919
this.xSlope = (this.destinyX-this.xCoord)/length * 2;
2020
this.ySlope = (this.destinyY-this.yCoord)/length * 2;
2121
this.maxSteps = this.xSlope === 0 ? (this.destinyY-this.yCoord)/this.ySlope : (this.destinyX-this.xCoord)/this.xSlope;
22-
this.steps = 0;
23-
}
24-
25-
26-
display() {
27-
noStroke();
28-
29-
this.charge > 0 ? fill(255) : fill(0);
30-
rect(this.xCoord, this.yCoord, this.size, this.size);
31-
this.move();
32-
}
33-
34-
move() {
35-
this.xCoord += this.xSlope;
36-
this.yCoord += this.ySlope;
37-
this.steps++;
38-
39-
if (this.steps >= this.maxSteps) {
40-
this.destinyNeuron.addCharge(this.charge);
41-
delete actionPotentialList[`${this.id}`];
42-
}
43-
}
44-
45-
static displayAllActionPotentials() {
46-
let keys = _.keys(actionPotentialList);
47-
for(var i=0; i<keys.length;i++) {
48-
actionPotentialList[keys[i]].display();
49-
}
50-
}
51-
}
22+
this.steps = 0;
23+
}
24+
25+
26+
display() {
27+
noStroke();
28+
29+
this.charge > 0 ? fill(255) : fill(0);
30+
rect(this.xCoord, this.yCoord, this.size, this.size);
31+
this.move();
32+
}
33+
34+
move() {
35+
this.xCoord += this.xSlope;
36+
this.yCoord += this.ySlope;
37+
this.steps++;
38+
39+
if (this.steps >= this.maxSteps) {
40+
this.destinyNeuron.addCharge(this.charge);
41+
delete actionPotentialList[`${this.id}`];
42+
}
43+
}
44+
45+
static displayAllActionPotentials() {
46+
let keys = _.keys(actionPotentialList);
47+
for(var i=0; i<keys.length;i++) {
48+
actionPotentialList[keys[i]].display();
49+
}
50+
}
51+
}

characterNeuron.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
'use strict';
22

33
class CharacterNeuron extends Neuron {
4-
constructor(x, y, neuronSize, actlvl) {
5-
super(x, y, neuronSize, actlvl);
6-
this.charIndex = [0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
7-
}
4+
constructor(x, y, neuronSize, actlvl) {
5+
super(x, y, neuronSize, actlvl);
6+
this.charIndex = [0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
7+
}
88

9-
display() {
10-
this.selected ? fill(200, 200, 60) : fill(255, 255, 255);
11-
stroke(sketchOptions.gridColor);
12-
rect(this.xCoord, this.yCoord, this.size, this.size);
13-
fill(0);
14-
textAlign(CENTER);
15-
textSize(this.size);
9+
display() {
10+
this.selected ? fill(200, 200, 60) : fill(255, 255, 255);
11+
stroke(sketchOptions.gridColor);
12+
rect(this.xCoord, this.yCoord, this.size, this.size);
13+
fill(0);
14+
textAlign(CENTER);
15+
textSize(this.size);
1616

17-
let letter = '';
18-
this.curCharge < 0 ? letter = this.curCharge : letter = this.charIndex[this.curCharge];
19-
text(letter, this.xCoord + this.size/2, this.yCoord + this.size/1.15);
20-
}
21-
}
17+
let letter = '';
18+
this.curCharge < 0 ? letter = this.curCharge : letter = this.charIndex[this.curCharge];
19+
text(letter, this.xCoord + this.size/2, this.yCoord + this.size/1.15);
20+
}
21+
}

exampleNeuronNets.js

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

+52-52
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<html>
2-
<head>
3-
<meta charset='UTF-8'>
2+
<head>
3+
<meta charset='UTF-8'>
44
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.6.1/lodash.min.js'></script>
55
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js'></script>
66
<script src='https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.4.20/p5.min.js'></script>
@@ -14,60 +14,60 @@
1414
<script src='exampleNeuronNets.js'></script>
1515
<script src='sketch.js'></script>
1616
<script src='userDomInteractions.js'></script>
17-
<link rel='shortcut icon' type='image/x-icon' href='favicon.ico' />
18-
<link rel='stylesheet' type='text/css' href='style.css'>
19-
<link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
20-
<title>Neural Playground</title>
21-
</head>
17+
<link rel='shortcut icon' type='image/x-icon' href='favicon.ico' />
18+
<link rel='stylesheet' type='text/css' href='style.css'>
19+
<link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
20+
<title>Neural Playground</title>
21+
</head>
2222

23-
<body>
24-
<div id='control-panel'>
25-
<div id='neuron-placement' class='column-left active' data-state='neuronPlacement'>
26-
<p>Place/Delete Neurons</p>
27-
Neuron Type:
28-
<select id='neuronType'>
29-
<option value='normal'>Normal</option>
30-
<option value='character'>Character</option>
31-
<option value='negative'>Negative</option>
32-
<option value='timer'>Timer</option>
33-
<option value='note'>Note</option>
34-
</select><br>
23+
<body>
24+
<div id='control-panel'>
25+
<div id='neuron-placement' class='column-left active' data-state='neuronPlacement'>
26+
<p>Place/Delete Neurons</p>
27+
Neuron Type:
28+
<select id='neuronType'>
29+
<option value='normal'>Normal</option>
30+
<option value='character'>Character</option>
31+
<option value='negative'>Negative</option>
32+
<option value='timer'>Timer</option>
33+
<option value='note'>Note</option>
34+
</select><br>
3535

36-
<span id='activationLevelSpan'>
37-
Activation Level:
38-
<input type='number' name='quantity' min='1' max='36' value='2' id='activationLevel'>
39-
</span>
36+
<span id='activationLevelSpan'>
37+
Activation Level:
38+
<input type='number' name='quantity' min='1' max='36' value='2' id='activationLevel'>
39+
</span>
4040

41-
<span id='timerInputSpan' hidden>
42-
Timer in Seconds:
43-
<input type='number' min='.25' max='10' value='1' step='.25' id='timerActivationInput'>
44-
Times
45-
<input type='number' min='-1' max='500' placeholder='-1 for forever' step='1' id='timesInput'>
46-
</span>
41+
<span id='timerInputSpan' hidden>
42+
Timer in Seconds:
43+
<input type='number' min='.25' max='10' value='1' step='.25' id='timerActivationInput'>
44+
Times
45+
<input type='number' min='-1' max='500' placeholder='-1 for forever' step='1' id='timesInput'>
46+
</span>
4747

48-
<span id='noteInputSpan' hidden>
49-
<a target="_blank" href='https://newt.phys.unsw.edu.au/jw/graphics/notesinvert.GIF'>Notes C1 - C8</a>:
50-
<select id='noteInput'>
51-
</select>
52-
</span>
53-
</div>
48+
<span id='noteInputSpan' hidden>
49+
<a target="_blank" href='https://newt.phys.unsw.edu.au/jw/graphics/notesinvert.GIF'>Notes C1 - C8</a>:
50+
<select id='noteInput'>
51+
</select>
52+
</span>
53+
</div>
5454

55-
<div id='connection-placement' class='column-center' data-state='connectionPlacement'>
56-
<p>Place/Delete Connections</p>
57-
<input type="radio" name="connection" value="one" checked> One-way connections<br>
58-
<input type="radio" name="connection" value="two"> Two-way connections
59-
</div>
55+
<div id='connection-placement' class='column-center' data-state='connectionPlacement'>
56+
<p>Place/Delete Connections</p>
57+
<input type="radio" name="connection" value="one" checked> One-way connections<br>
58+
<input type="radio" name="connection" value="two"> Two-way connections
59+
</div>
6060

61-
<div id='live-mode' class='column-right' data-state='live'>
62-
<p>Live Mode</p>
63-
</div>
64-
</div>
61+
<div id='live-mode' class='column-right' data-state='live'>
62+
<p>Live Mode</p>
63+
</div>
64+
</div>
6565

66-
<span id='loadExamples'>
67-
Load Example:
68-
<select placeholder='Select Example' id='exampleInput'>
69-
<option value="" disabled selected>Select Example</option>
70-
</select>
71-
</span>
72-
</body>
73-
</html>
66+
<span id='loadExamples'>
67+
Load Example:
68+
<select placeholder='Select Example' id='exampleInput'>
69+
<option value="" disabled selected>Select Example</option>
70+
</select>
71+
</span>
72+
</body>
73+
</html>

negativeNeuron.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
'use strict';
22

33
class NegativeNeuron extends Neuron {
4-
constructor(x, y, neuronSize, actlvl) {
5-
super(x, y, neuronSize, actlvl);
6-
this.actionPotentialCharge = -1;
7-
}
4+
constructor(x, y, neuronSize, actlvl) {
5+
super(x, y, neuronSize, actlvl);
6+
this.actionPotentialCharge = -1;
7+
}
88

9-
display() {
10-
this.selected ? fill(200, 200, 60) : fill(0, 100, 200);
11-
stroke(sketchOptions.gridColor);
12-
rect(this.xCoord, this.yCoord, this.size, this.size);
13-
}
14-
}
9+
display() {
10+
this.selected ? fill(200, 200, 60) : fill(0, 100, 200);
11+
stroke(sketchOptions.gridColor);
12+
rect(this.xCoord, this.yCoord, this.size, this.size);
13+
}
14+
}

0 commit comments

Comments
 (0)