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.

150 lines
4.0KB

  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. switch (index) {
  56. case 0: // color
  57. updateColor(parseInt(Math.round(value)));
  58. break;
  59. case 1: // out-left
  60. value = (fOutLeft * kSmoothMultiplier + value) / (kSmoothMultiplier + 1.0);
  61. /**/ if (value < 0.001) value = 0.0;
  62. else if (value > 0.999) value = 1.0;
  63. if (fOutLeft != value)
  64. {
  65. fOutLeft = value;
  66. repaint();
  67. }
  68. break;
  69. case 2: // out-right
  70. value = (fOutRight * kSmoothMultiplier + value) / (kSmoothMultiplier + 1.0);
  71. /**/ if (value < 0.001) value = 0.0;
  72. else if (value > 0.999) value = 1.0;
  73. if (fOutRight != value)
  74. {
  75. fOutRight = value;
  76. repaint();
  77. }
  78. break;
  79. }
  80. }
  81. </script>
  82. <style>
  83. html, body {
  84. background: grey;
  85. color: white;
  86. margin: 0;
  87. padding: 0;
  88. }
  89. body {
  90. display: flex;
  91. flex-direction: column;
  92. }
  93. p {
  94. margin: 6px;
  95. font-size: 15px;
  96. overflow: hidden;
  97. text-overflow: ellipsis;
  98. width: calc(100% - 12px);
  99. height: 15px;
  100. white-space: nowrap;
  101. }
  102. #meters {
  103. display: flex;
  104. flex-direction: row;
  105. }
  106. .meter {
  107. background: black;
  108. margin: 6px;
  109. margin-top: 0px;
  110. width: calc(50vw - 9px);
  111. height: calc(100vh - 12px - 6px - 15px);
  112. }
  113. .meter:first-child {
  114. margin-right: 3px;
  115. }
  116. .meter:last-child {
  117. margin-left: 3px;
  118. }
  119. .meter-x {
  120. background: rgb(93, 231, 61);
  121. position: relative;
  122. top: 0%;
  123. left: 0;
  124. width: 100%;
  125. height: 0%;
  126. }
  127. </style>
  128. </head>
  129. <body>
  130. <p id="user-agent">&nbsp;</p>
  131. <div id="meters">
  132. <div class="meter" id="left-meter">
  133. <div class="meter-x" id="left-meter-x"></div>
  134. </div>
  135. <div class="meter" id="right-meter">
  136. <div class="meter-x" id="right-meter-x"></div>
  137. </div>
  138. </div>
  139. </body>
  140. </html>