nearest.html 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. <form class="panel config" onsubmit="onUpdate(event)">
  20. <div class="container control">
  21. <img src="https://img.pokemondb.net/sprites/sword-shield/icon/bulbasaur.png" />
  22. <button class="padded" type="button" onclick="onRandomColor()">Random color</button>
  23. <input size="7" maxlength="7" id="color-input" oninput="onUpdate()"
  24. value="#ffffff" />
  25. </div>
  26. <div class="container control">
  27. <label for="include-x">Include X:</label>
  28. <input type="checkbox" checked oninput="onUpdate()" id="include-x">
  29. </div>
  30. <div class="container control">
  31. <label for="norm-q-y">Normalize q and Y:</label>
  32. <input type="checkbox" oninput="onUpdate()" id="norm-q-y">
  33. </div>
  34. <div class="container control">
  35. <label for="close-coeff">Closeness coefficient: <span id="close-coeff-display">2</span></label>
  36. <input type="range" min="0" max="10" value="2" step="0.1" oninput="onUpdate()" id="close-coeff">
  37. </div>
  38. <div class="container control">
  39. <label for="num-poke" style="min-width: 200px;">
  40. Search limit: <span id="num-poke-display">10</span>
  41. </label>
  42. <input type="range" min="1" max="100" value="10" oninput="onUpdate()" id="num-poke">
  43. </div>
  44. </form>
  45. <div class="container center-aligned">
  46. <div>
  47. <math xmlns="http://www.w3.org/1998/Math/MathML">
  48. <semantics>
  49. <mrow>
  50. <mi>X</mi>
  51. <mrow>
  52. <mo>(</mo>
  53. <mi>P</mi>
  54. <mo>)</mo>
  55. </mrow>
  56. <mo>=</mo>
  57. <mfrac>
  58. <mn>1</mn>
  59. <mrow>
  60. <mo>|</mo>
  61. <mi>P</mi>
  62. <mo>|</mo>
  63. </mrow>
  64. </mfrac>
  65. <munder>
  66. <mo>∑</mo>
  67. <mrow>
  68. <mi>p</mi>
  69. <mo>∊</mo>
  70. <mi>P</mi>
  71. </mrow>
  72. </munder>
  73. <msup>
  74. <mrow>
  75. <mo>|</mo>
  76. <mrow>
  77. <mo>|</mo>
  78. <mover>
  79. <mi>p</mi>
  80. <mo stretchy="false">⇀</mo>
  81. </mover>
  82. <mo>|</mo>
  83. </mrow>
  84. <mo>|</mo>
  85. </mrow>
  86. <mn>2</mn>
  87. </msup>
  88. </mrow>
  89. <annotation encoding="TeX">X\\left(P\\right) = \\frac{1}{\\left|P\\right|}\\sum_{p\\in
  90. P}{\\left|\\left|\\vec{p}\\right|\\right|^2}</annotation>
  91. </semantics>
  92. </math>
  93. </div>
  94. <div>
  95. <math xmlns="http://www.w3.org/1998/Math/MathML">
  96. <semantics>
  97. <mrow>
  98. <mover>
  99. <mi>Y</mi>
  100. <mo stretchy="false">⇀</mo>
  101. </mover>
  102. <mrow>
  103. <mo>(</mo>
  104. <mi>P</mi>
  105. <mo>)</mo>
  106. </mrow>
  107. <mo>=</mo>
  108. <mfrac>
  109. <mn>1</mn>
  110. <mrow>
  111. <mo>|</mo>
  112. <mi>P</mi>
  113. <mo>|</mo>
  114. </mrow>
  115. </mfrac>
  116. <munder>
  117. <mo>∑</mo>
  118. <mrow>
  119. <mi>p</mi>
  120. <mo>∊</mo>
  121. <mi>P</mi>
  122. </mrow>
  123. </munder>
  124. <mover>
  125. <mi>p</mi>
  126. <mo stretchy="false">⇀</mo>
  127. </mover>
  128. </mrow>
  129. <annotation encoding="TeX">Y\\left(P\\right) = \\frac{1}{\\left|P\\right|}\\sum_{p\\in
  130. P}{\\vec{p}}</annotation>
  131. </semantics>
  132. </math>
  133. </div>
  134. </div>
  135. <div class="container center-aligned">
  136. Minimizing: <span id="obj-fn">X(P) - 2q&sdot;Y(P)</span>
  137. </div>
  138. <div class="panel bypkmn">
  139. <form class="container control" onsubmit="onUpdate(event)">
  140. <label for="pokemon-name">Search By Pokemon</label>
  141. <input id="pokemon-name" size="15" oninput="onUpdate()">
  142. </form>
  143. <ul id="search-list" class="pkmn-list"></ul>
  144. </div>
  145. </div>
  146. <div class="padded panel">
  147. <div class="title">CIECAM02 Uniform Color Space</div>
  148. <ul id="best-list-jab" class="pkmn-list"></ul>
  149. </div>
  150. <div class="padded panel" style="flex: 1">
  151. <div class="title">sRGB Color Space</div>
  152. <ul id="best-list-rgb" class="pkmn-list"></ul>
  153. </div>
  154. </div>
  155. </body>
  156. </html>