Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="nl">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Welke Kleur?</title>
  6. </head>
  7. <body>
  8. <h1>Welke Kleur?</h1>
  9. <p>Gemaakt door Bastiaan van der Plaat</p>
  10. <p><input type="color" id="color_input"></p>
  11. <p>Kleur: <b id="color_text">none</b></p>
  12. <script src="brain.js"></script>
  13. <script>
  14. var color_input = document.getElementById('color_input');
  15. var color_text = document.getElementById('color_text');
  16. const network = new brain.NeuralNetwork();
  17. network.train([
  18. {input: { r: 0, g: 0, b: 0 }, output: { black: 1 }},
  19. {input: { r: 255, g: 0, b: 0 }, output: { red: 1 }},
  20. {input: { r: 0, g: 255, b: 0 }, output: { green: 1 }},
  21. {input: { r: 0, g: 0, b: 255 }, output: { blue: 1 }},
  22. {input: { r: 255, g: 255, b: 255 }, output: { white: 1 }}
  23. ], { iterations: 20000 });
  24. color_input.onchange = function () {
  25. color_text.textContent = JSON.stringify(network.run({
  26. r: parseInt(color_input.value.substring(1, 3), 16),
  27. g: parseInt(color_input.value.substring(3, 5), 16),
  28. b: parseInt(color_input.value.substring(5, 7), 16)
  29. }));
  30. };
  31. </script>
  32. </body>
  33. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement