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.

221 lines
4.3KB

  1. #pragma once
  2. #include "app.hpp"
  3. namespace rack {
  4. enum ColorNames {
  5. COLOR_BLACK,
  6. COLOR_WHITE,
  7. COLOR_RED,
  8. COLOR_ORANGE,
  9. COLOR_YELLOW,
  10. COLOR_GREEN,
  11. COLOR_CYAN,
  12. COLOR_BLUE,
  13. COLOR_PURPLE,
  14. NUM_COLORS
  15. };
  16. extern const NVGcolor colors[NUM_COLORS];
  17. ////////////////////
  18. // Knobs
  19. ////////////////////
  20. struct SynthTechAlco : SpriteKnob {
  21. SynthTechAlco() {
  22. box.size = Vec(45, 45);
  23. spriteOffset = Vec(-3, -2);
  24. spriteSize = Vec(51, 51);
  25. minIndex = 49;
  26. maxIndex = -51;
  27. spriteCount = 120;
  28. spriteImage = Image::load("res/ComponentLibrary/SynthTechAlco.png");
  29. }
  30. };
  31. struct Davies1900hKnob : SVGKnob {
  32. Davies1900hKnob() {
  33. box.size = Vec(36, 36);
  34. minAngle = -0.75*M_PI;
  35. maxAngle = 0.75*M_PI;
  36. }
  37. };
  38. struct Davies1900hWhiteKnob : Davies1900hKnob {
  39. Davies1900hWhiteKnob() {
  40. setSVG(SVG::load("res/ComponentLibrary/Davies1900hWhite.svg"));
  41. }
  42. };
  43. struct Davies1900hBlackKnob : Davies1900hKnob {
  44. Davies1900hBlackKnob() {
  45. setSVG(SVG::load("res/ComponentLibrary/Davies1900hBlack.svg"));
  46. }
  47. };
  48. struct Davies1900hRedKnob : Davies1900hKnob {
  49. Davies1900hRedKnob() {
  50. setSVG(SVG::load("res/ComponentLibrary/Davies1900hRed.svg"));
  51. }
  52. };
  53. struct BefacoBigKnob : SVGKnob {
  54. BefacoBigKnob() {
  55. box.size = Vec(75, 75);
  56. minAngle = -0.75*M_PI;
  57. maxAngle = 0.75*M_PI;
  58. setSVG(SVG::load("res/ComponentLibrary/BefacoBigKnob.svg"));
  59. }
  60. };
  61. struct BefacoTinyKnob : SVGKnob {
  62. BefacoTinyKnob() {
  63. box.size = Vec(26, 26);
  64. minAngle = -0.75*M_PI;
  65. maxAngle = 0.75*M_PI;
  66. setSVG(SVG::load("res/ComponentLibrary/BefacoTinyKnob.svg"));
  67. }
  68. };
  69. struct BefacoSlidePot : SpriteKnob {
  70. BefacoSlidePot() {
  71. box.size = Vec(12, 122);
  72. spriteOffset = Vec(-2, -6);
  73. spriteSize = Vec(18, 134);
  74. minIndex = 97;
  75. maxIndex = 0;
  76. spriteCount = 98;
  77. spriteImage = Image::load("res/ComponentLibrary/BefacoSlidePot.png");
  78. }
  79. };
  80. ////////////////////
  81. // Jacks
  82. ////////////////////
  83. struct PJ301MPort : Port {
  84. PJ301MPort() {
  85. box.size = Vec(24, 24);
  86. spriteOffset = Vec(-2, -2);
  87. spriteSize = Vec(30, 30);
  88. spriteImage = Image::load("res/ComponentLibrary/PJ301M.png");
  89. }
  90. };
  91. struct PJ3410Port : Port {
  92. PJ3410Port() {
  93. box.size = Vec(32, 31);
  94. spriteOffset = Vec(-1, -1);
  95. spriteSize = Vec(36, 36);
  96. spriteImage = Image::load("res/ComponentLibrary/PJ3410.png");
  97. }
  98. };
  99. struct CL1362Port : Port {
  100. CL1362Port() {
  101. box.size = Vec(33, 29);
  102. spriteOffset = Vec(-2, -2);
  103. spriteSize = Vec(39, 36);
  104. spriteImage = Image::load("res/ComponentLibrary/CL1362.png");
  105. }
  106. };
  107. ////////////////////
  108. // Lights
  109. ////////////////////
  110. struct ValueLight : Light {
  111. float *value;
  112. };
  113. template <int COLOR>
  114. struct ColorValueLight : ValueLight {
  115. void step() {
  116. float v = sqrtBipolar(getf(value));
  117. color = nvgLerpRGBA(colors[COLOR_BLACK], colors[COLOR], v);
  118. }
  119. };
  120. typedef ColorValueLight<COLOR_RED> RedValueLight;
  121. typedef ColorValueLight<COLOR_YELLOW> YellowValueLight;
  122. typedef ColorValueLight<COLOR_GREEN> GreenValueLight;
  123. template <int COLOR_POS, int COLOR_NEG>
  124. struct PolarityLight : ValueLight {
  125. void step() {
  126. float v = sqrtBipolar(getf(value));
  127. if (v >= 0.0)
  128. color = nvgLerpRGBA(colors[COLOR_BLACK], colors[COLOR_POS], v);
  129. else
  130. color = nvgLerpRGBA(colors[COLOR_BLACK], colors[COLOR_NEG], -v);
  131. }
  132. };
  133. typedef PolarityLight<COLOR_GREEN, COLOR_RED> GreenRedPolarityLight;
  134. template <typename BASE>
  135. struct LargeLight : BASE {
  136. LargeLight() {
  137. this->box.size = Vec(20, 20);
  138. }
  139. };
  140. template <typename BASE>
  141. struct MediumLight : BASE {
  142. MediumLight() {
  143. this->box.size = Vec(12, 12);
  144. }
  145. };
  146. template <typename BASE>
  147. struct SmallLight : BASE {
  148. SmallLight() {
  149. this->box.size = Vec(8, 8);
  150. }
  151. };
  152. ////////////////////
  153. // Misc
  154. ////////////////////
  155. /** If you don't add these to your ModuleWidget, it will fall out of the rack... */
  156. struct Screw : SpriteWidget {
  157. Screw() {
  158. box.size = Vec(15, 14);
  159. spriteOffset = Vec(0, 0);
  160. spriteSize = Vec(15, 14);
  161. }
  162. };
  163. struct BlackScrew : Screw {
  164. BlackScrew() {
  165. spriteImage = Image::load("res/ComponentLibrary/ScrewBlack.png");
  166. }
  167. };
  168. struct SilverScrew : Screw {
  169. SilverScrew() {
  170. spriteImage = Image::load("res/ComponentLibrary/ScrewSilver.png");
  171. }
  172. };
  173. struct LightPanel : Panel {
  174. LightPanel() {
  175. backgroundColor = nvgRGB(0xe8, 0xe8, 0xe8);
  176. borderColor = nvgRGB(0xa1, 0xa1, 0xa1);
  177. }
  178. };
  179. struct DarkPanel : Panel {
  180. DarkPanel() {
  181. backgroundColor = nvgRGB(0x17, 0x17, 0x17);
  182. borderColor = nvgRGB(0x5e, 0x5e, 0x5e);
  183. }
  184. };
  185. } // namespace rack