-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0823780
commit 09848be
Showing
31 changed files
with
566 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
class IOLayer extends LayerView { | ||
constructor(name, data, _x, _y) { | ||
const { x, y } = iManager.getAbsoluteCoordinates(_x, _y); | ||
super(x, y, 300, 300); | ||
this.name = name; | ||
this.data = data; | ||
} | ||
|
||
isInput() { | ||
return this.outputDot !== null; | ||
} | ||
|
||
getDot() { | ||
return this.inputDot ?? this.outputDot; | ||
} | ||
|
||
updateNeuronsCoordinates() { | ||
this.neurons.forEach((n, i) => { | ||
const x = this.x - 25 + (this.isInput() ? this.w : 50); | ||
n.updateCoordinates(x, this.y + 30 + i * 50); | ||
}); | ||
this.updateBorders(); | ||
} | ||
|
||
updateBorders() { | ||
this.h = this.neurons[this.neurons.length - 1].y - this.y + 30; | ||
this.getDot().updateCoordinates(); | ||
} | ||
|
||
reInitializeNeurons() { | ||
const varNum = this.data[0].length; | ||
for (let i = 0; i < varNum; i++) { | ||
const neuron = new NeuronView(); | ||
this.neurons.push(neuron); | ||
} | ||
this.updateNeuronsCoordinates(); | ||
} | ||
|
||
pressed() { | ||
iManager.checkRollout(this); | ||
this.getDot().handlePressed(); | ||
} | ||
|
||
setCoordinates(x, y) { | ||
super.setCoordinates(x, y); | ||
} | ||
|
||
createColCommand(text, x, y) { | ||
return { | ||
func: "text", | ||
args: [text, this.x + 25 + x, this.y + 25 + y, this.w, this.h], | ||
}; | ||
} | ||
|
||
doubleClicked() {} | ||
|
||
draw() { | ||
this.isEditModeOpen() && this.getDot().draw(); | ||
const commands = [...this.outerCommands(), ...this.dataCommands()]; | ||
executeDrawingCommands(commands); | ||
|
||
this.neurons.forEach((n) => n.draw()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
class InputLayer extends IOLayer { | ||
constructor(name, data) { | ||
super(name, data, 300, 300, true); | ||
this.initializeDot(); | ||
this.reInitializeNeurons(); | ||
} | ||
|
||
initializeDot() { | ||
this.outputDot = new Dot(this, true); | ||
} | ||
|
||
dataCommands() { | ||
let commands = []; | ||
this.data.forEach((row, i) => { | ||
row.forEach((val, j) => { | ||
const a = this.createColCommand(val, i * 50, j * 50); | ||
commands.push(a); | ||
}); | ||
}); | ||
return commands; | ||
} | ||
|
||
outerCommands() { | ||
const commands = [ | ||
{ func: "rect", args: [this.x, this.y, this.w, this.h, 10, 10] }, | ||
{ | ||
func: "text", | ||
args: [this.name + " Input", this.x + 5, this.y - 20, this.w, this.h], | ||
}, | ||
{ | ||
func: "line", | ||
args: [this.x + 50, this.y + 15, this.x + 50, this.y + this.h - 15], | ||
}, | ||
]; | ||
return commands; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
class OutputLayer extends IOLayer { | ||
constructor(name, data) { | ||
super(name, data, 800, 300, false); | ||
this.initializeDot(); | ||
this.reInitializeNeurons(); | ||
} | ||
|
||
initializeDot() { | ||
this.inputDot = new Dot(this); | ||
} | ||
|
||
dataCommands() { | ||
let commands = []; | ||
this.data.forEach((val, i) => { | ||
const a = this.createColCommand(val, (i + 1) * 50, 0); | ||
commands.push(a); | ||
}); | ||
return commands; | ||
} | ||
|
||
outerCommands() { | ||
const commands = [ | ||
{ func: "rect", args: [this.x, this.y, this.w, this.h, 10, 10] }, | ||
{ | ||
func: "text", | ||
args: [this.name + " Output", this.x + 5, this.y - 20, this.w, this.h], | ||
}, | ||
{ | ||
func: "line", | ||
args: [ | ||
this.x + this.w - 50, | ||
this.y + 15, | ||
this.x + this.w - 50, | ||
this.y + this.h - 15, | ||
], | ||
}, | ||
]; | ||
return commands; | ||
} | ||
} |
Oops, something went wrong.