DISTRHO Plugin Framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
4.1KB

  1. <!DOCTYPE html>
  2. <html lang="">
  3. <head>
  4. <meta charset="utf-8">
  5. <title></title>
  6. <script>
  7. const METER_COLOR_GREEN = 0;
  8. const METER_COLOR_BLUE = 1;
  9. const kSmoothMultiplier = 3.0;
  10. let fColorValue = null;
  11. let fColor = 'rgb(93, 231, 61)';
  12. let fOutLeft = 0.0;
  13. let fOutRight = 0.0;
  14. setTimeout(function() {
  15. document.getElementById('user-agent').textContent = window.navigator.userAgent;
  16. document.getElementById('left-meter').onclick = function() {
  17. console.log("left meter clicked");
  18. fColorValue = fColorValue == 1 ? 0 : 1;
  19. updateColor(fColorValue, true);
  20. setParameterValue(0, fColorValue);
  21. repaint();
  22. }
  23. document.getElementById('right-meter').onclick = function() {
  24. console.log("right meter clicked");
  25. fColorValue = fColorValue == 1 ? 0 : 1;
  26. updateColor(fColorValue, true);
  27. setParameterValue(0, fColorValue);
  28. repaint();
  29. }
  30. }, 1)
  31. function repaint() {
  32. const lmeter = document.getElementById('left-meter-x');
  33. const rmeter = document.getElementById('right-meter-x');
  34. lmeter.setAttribute('style', 'background:' + fColor + ';top:' + (100 * (1.0 - fOutLeft)) + '%;height:' + (100 * fOutLeft) + '%');
  35. rmeter.setAttribute('style', 'background:' + fColor + ';top:' + (100 * (1.0 - fOutRight)) + '%;height:' + (100 * fOutRight) + '%');
  36. setTimeout(function() {
  37. setState('reset', '');
  38. }, 1)
  39. }
  40. function updateColor(color, forced) {
  41. if (fColorValue === color && !forced)
  42. return;
  43. fColorValue = color;
  44. switch (color) {
  45. case METER_COLOR_GREEN:
  46. fColor = "rgb(93, 231, 61)";
  47. break;
  48. case METER_COLOR_BLUE:
  49. fColor = "rgb(82, 238, 248)";
  50. break;
  51. }
  52. repaint();
  53. }
  54. function parameterChanged(index, value) {
  55. // console.log("paramChanged", index, value)
  56. switch (index) {
  57. case 0: // color
  58. updateColor(parseInt(Math.round(value)));
  59. break;
  60. case 1: // out-left
  61. value = (fOutLeft * kSmoothMultiplier + value) / (kSmoothMultiplier + 1.0);
  62. /**/ if (value < 0.001) value = 0.0;
  63. else if (value > 0.999) value = 1.0;
  64. if (fOutLeft != value)
  65. {
  66. fOutLeft = value;
  67. repaint();
  68. }
  69. break;
  70. case 2: // out-right
  71. value = (fOutRight * kSmoothMultiplier + value) / (kSmoothMultiplier + 1.0);
  72. /**/ if (value < 0.001) value = 0.0;
  73. else if (value > 0.999) value = 1.0;
  74. if (fOutRight != value)
  75. {
  76. fOutRight = value;
  77. repaint();
  78. }
  79. break;
  80. }
  81. }
  82. </script>
  83. <style>
  84. html, body {
  85. background: grey;
  86. color: white;
  87. margin: 0;
  88. padding: 0;
  89. }
  90. body {
  91. display: flex;
  92. flex-direction: column;
  93. }
  94. p {
  95. margin: 6px;
  96. font-size: 15px;
  97. overflow: hidden;
  98. text-overflow: ellipsis;
  99. width: calc(100% - 12px);
  100. height: 15px;
  101. white-space: nowrap;
  102. }
  103. #meters {
  104. display: flex;
  105. flex-direction: row;
  106. }
  107. .meter {
  108. background: black;
  109. margin: 6px;
  110. margin-top: 0px;
  111. width: calc(50vw - 9px);
  112. height: calc(100vh - 12px - 6px - 15px);
  113. }
  114. .meter:first-child {
  115. margin-right: 3px;
  116. }
  117. .meter:last-child {
  118. margin-left: 3px;
  119. }
  120. .meter-x {
  121. background: rgb(93, 231, 61);
  122. position: relative;
  123. top: 0%;
  124. left: 0;
  125. width: 100%;
  126. height: 0%;
  127. }
  128. </style>
  129. </head>
  130. <body>
  131. <p id="user-agent">&nbsp;</p>
  132. <div id="meters">
  133. <div class="meter" id="left-meter">
  134. <div class="meter-x" id="left-meter-x"></div>
  135. </div>
  136. <div class="meter" id="right-meter">
  137. <div class="meter-x" id="right-meter-x"></div>
  138. </div>
  139. </div>
  140. </body>
  141. </html>