CodingTrain / Toy-Neural-Network-JS

Neural Network JavaScript library for Coding Train tutorials
MIT License
425 stars 242 forks source link

Changing colors to rainbow colors #104

Open jonathan-richer opened 6 years ago

jonathan-richer commented 6 years ago

Rainbow!

I changed the colorMode to HSB and the fill arguents to work with, so it looks more like:

In setup:

colorMode(HSB);

And draw:

for (let i = 0; i < cols; i++) {
    for (let j = 0; j < rows; j++) {
      let x1 = i / cols;
      let x2 = j / rows;
      let inputs = [x1, x2];
      let y = nn.predict(inputs);
      noStroke();
      fill(y * 360, 100, 100);
      rect(i * resolution, j * resolution, resolution, resolution);
}