nearest.html 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Pokemon By Color</title>
  6. <link rel="stylesheet" href="nearest.css">
  7. <script src="https://unpkg.com/d3-color@3.0.1/dist/d3-color.min.js"></script>
  8. <script src="https://unpkg.com/d3-cam02@0.1.5/build/d3-cam02.min.js"></script>
  9. <script src="https://unpkg.com/fuse.js@6.5.3/dist/fuse.min.js"></script>
  10. <script src="https://unpkg.com/texzilla@1.0.2/TeXZilla.js"></script>
  11. <script src="database.js"></script>
  12. <script src="nearest.js"></script>
  13. <script lang="javascript">window.onload = () => { onUpdate(); }</script>
  14. </head>
  15. <body>
  16. <noscript>Requires javascript</noscript>
  17. <div class="container">
  18. <div id="left-panel" class="padded panel">
  19. <div class="container center-aligned">
  20. <div>
  21. <math xmlns="http://www.w3.org/1998/Math/MathML">
  22. <semantics>
  23. <mrow>
  24. <mi>X</mi>
  25. <mrow>
  26. <mo>(</mo>
  27. <mi>P</mi>
  28. <mo>)</mo>
  29. </mrow>
  30. <mo>=</mo>
  31. <mfrac>
  32. <mn>1</mn>
  33. <mrow>
  34. <mo>|</mo>
  35. <mi>P</mi>
  36. <mo>|</mo>
  37. </mrow>
  38. </mfrac>
  39. <munder>
  40. <mo>∑</mo>
  41. <mrow>
  42. <mi>p</mi>
  43. <mo>∊</mo>
  44. <mi>P</mi>
  45. </mrow>
  46. </munder>
  47. <msup>
  48. <mrow>
  49. <mo>|</mo>
  50. <mrow>
  51. <mo>|</mo>
  52. <mover>
  53. <mi>p</mi>
  54. <mo stretchy="false">⇀</mo>
  55. </mover>
  56. <mo>|</mo>
  57. </mrow>
  58. <mo>|</mo>
  59. </mrow>
  60. <mn>2</mn>
  61. </msup>
  62. </mrow>
  63. <annotation encoding="TeX">X\\left(P\\right) = \\frac{1}{\\left|P\\right|}\\sum_{p\\in
  64. P}{\\left|\\left|\\vec{p}\\right|\\right|^2}</annotation>
  65. </semantics>
  66. </math>
  67. </div>
  68. <div>
  69. <math xmlns="http://www.w3.org/1998/Math/MathML">
  70. <semantics>
  71. <mrow>
  72. <mover>
  73. <mi>Y</mi>
  74. <mo stretchy="false">⇀</mo>
  75. </mover>
  76. <mrow>
  77. <mo>(</mo>
  78. <mi>P</mi>
  79. <mo>)</mo>
  80. </mrow>
  81. <mo>=</mo>
  82. <mfrac>
  83. <mn>1</mn>
  84. <mrow>
  85. <mo>|</mo>
  86. <mi>P</mi>
  87. <mo>|</mo>
  88. </mrow>
  89. </mfrac>
  90. <munder>
  91. <mo>∑</mo>
  92. <mrow>
  93. <mi>p</mi>
  94. <mo>∊</mo>
  95. <mi>P</mi>
  96. </mrow>
  97. </munder>
  98. <mover>
  99. <mi>p</mi>
  100. <mo stretchy="false">⇀</mo>
  101. </mover>
  102. </mrow>
  103. <annotation encoding="TeX">Y\\left(P\\right) = \\frac{1}{\\left|P\\right|}\\sum_{p\\in
  104. P}{\\vec{p}}</annotation>
  105. </semantics>
  106. </math>
  107. </div>
  108. </div>
  109. <div class="container center-aligned">
  110. Minimizing: <span id="obj-fn">X(P) - 2q&sdot;Y(P)</span>
  111. </div>
  112. <form class="panel" onsubmit="onUpdate(event)">
  113. <div class="container control">
  114. <label for="include-x">Include X:</label>
  115. <input type="checkbox" checked oninput="onUpdate()" id="include-x">
  116. </div>
  117. <div class="container control">
  118. <label for="norm-q-y">Normalize q and Y:</label>
  119. <input type="checkbox" oninput="onUpdate()" id="norm-q-y">
  120. </div>
  121. <div class="container control">
  122. <label for="close-coeff">Closeness coefficient: <span id="close-coeff-display">2</span></label>
  123. <input type="range" min="0" max="10" value="2" step="0.1" oninput="onUpdate()" id="close-coeff">
  124. </div>
  125. <div class="container control">
  126. <div>Color Space: <span id="color-space">CAM02-UCS</span></div>
  127. <button id="space-toggle" type="button" onclick="onToggleSpace()">Swap to RGB</button>
  128. </div>
  129. </form>
  130. <div class="panel bypkmn">
  131. <form class="container control" onsubmit="onUpdate(event)">
  132. <label for="pokemon-name">Search By Pokemon</label>
  133. <input id="pokemon-name" size="15" oninput="onUpdate()">
  134. </form>
  135. <ul id="search-list" class="pkmn-list"></ul>
  136. </div>
  137. </div>
  138. <div class="padded panel bycolor">
  139. <div>
  140. Search By Color - click random, or enter six digit hex code (optional #)
  141. </div>
  142. <form class="panel" onsubmit="onUpdate(event)">
  143. <div class="container bycolor_l1">
  144. <button class="padded" type="button" onclick="onRandomColor()">Random color</button>
  145. <input class="margined" size="7" maxlength="7" id="color-input" oninput="onUpdate()"
  146. value="#ffffff" />
  147. <img src="https://img.pokemondb.net/sprites/sword-shield/icon/bulbasaur.png" />
  148. </div>
  149. <div class="container bycolor_l2">
  150. <label for="num-poke" style="min-width: 200px;">Number to find: <span
  151. id="num-poke-display">10</span></label>
  152. <input type="range" min="1" max="100" value="10" oninput="onUpdate()" id="num-poke">
  153. </div>
  154. </form>
  155. <ul id="best-list" class="pkmn-list"></ul>
  156. </div>
  157. </div>
  158. </body>
  159. </html>