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.

230 lines
4.7KB

  1. #pragma once
  2. #include "scene.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. template <typename BASE>
  84. struct PJ301M : BASE {
  85. PJ301M() {
  86. this->box.size = Vec(24, 24);
  87. this->spriteOffset = Vec(-2, -2);
  88. this->spriteSize = Vec(30, 30);
  89. this->spriteImage = Image::load("res/ComponentLibrary/PJ301M.png");
  90. }
  91. };
  92. typedef PJ301M<InputPort> InputPortPJ301M;
  93. typedef PJ301M<OutputPort> OutputPortPJ301M;
  94. template <typename BASE>
  95. struct PJ3410 : BASE {
  96. PJ3410() {
  97. this->box.size = Vec(32, 31);
  98. this->spriteOffset = Vec(-1, -1);
  99. this->spriteSize = Vec(36, 36);
  100. this->spriteImage = Image::load("res/ComponentLibrary/PJ3410.png");
  101. }
  102. };
  103. typedef PJ3410<InputPort> InputPortPJ3410;
  104. typedef PJ3410<OutputPort> OutputPortPJ3410;
  105. template <typename BASE>
  106. struct CL1362 : BASE {
  107. CL1362() {
  108. this->box.size = Vec(33, 29);
  109. this->spriteOffset = Vec(-2, -2);
  110. this->spriteSize = Vec(39, 36);
  111. this->spriteImage = Image::load("res/ComponentLibrary/CL1362.png");
  112. }
  113. };
  114. typedef CL1362<InputPort> InputPortCL1362;
  115. typedef CL1362<OutputPort> OutputPortCL1362;
  116. ////////////////////
  117. // Lights
  118. ////////////////////
  119. struct ValueLight : Light {
  120. float *value;
  121. };
  122. template <int COLOR>
  123. struct ColorValueLight : ValueLight {
  124. void step() {
  125. float v = sqrtBipolar(getf(value));
  126. color = nvgLerpRGBA(colors[COLOR_BLACK], colors[COLOR], v);
  127. }
  128. };
  129. typedef ColorValueLight<COLOR_RED> RedValueLight;
  130. typedef ColorValueLight<COLOR_YELLOW> YellowValueLight;
  131. typedef ColorValueLight<COLOR_GREEN> GreenValueLight;
  132. template <int COLOR_POS, int COLOR_NEG>
  133. struct PolarityLight : ValueLight {
  134. void step() {
  135. float v = sqrtBipolar(getf(value));
  136. if (v >= 0.0)
  137. color = nvgLerpRGBA(colors[COLOR_BLACK], colors[COLOR_POS], v);
  138. else
  139. color = nvgLerpRGBA(colors[COLOR_BLACK], colors[COLOR_NEG], -v);
  140. }
  141. };
  142. typedef PolarityLight<COLOR_GREEN, COLOR_RED> GreenRedPolarityLight;
  143. template <typename BASE>
  144. struct LargeLight : BASE {
  145. LargeLight() {
  146. this->box.size = Vec(20, 20);
  147. }
  148. };
  149. template <typename BASE>
  150. struct MediumLight : BASE {
  151. MediumLight() {
  152. this->box.size = Vec(12, 12);
  153. }
  154. };
  155. template <typename BASE>
  156. struct SmallLight : BASE {
  157. SmallLight() {
  158. this->box.size = Vec(8, 8);
  159. }
  160. };
  161. ////////////////////
  162. // Misc
  163. ////////////////////
  164. /** If you don't add these to your ModuleWidget, it will fall out of the rack... */
  165. struct Screw : SpriteWidget {
  166. Screw() {
  167. box.size = Vec(15, 14);
  168. spriteOffset = Vec(0, 0);
  169. spriteSize = Vec(15, 14);
  170. }
  171. };
  172. struct BlackScrew : Screw {
  173. BlackScrew() {
  174. spriteImage = Image::load("res/ComponentLibrary/ScrewBlack.png");
  175. }
  176. };
  177. struct SilverScrew : Screw {
  178. SilverScrew() {
  179. spriteImage = Image::load("res/ComponentLibrary/ScrewSilver.png");
  180. }
  181. };
  182. struct LightPanel : Panel {
  183. LightPanel() {
  184. backgroundColor = nvgRGB(0xe8, 0xe8, 0xe8);
  185. borderColor = nvgRGB(0xa1, 0xa1, 0xa1);
  186. }
  187. };
  188. struct DarkPanel : Panel {
  189. DarkPanel() {
  190. backgroundColor = nvgRGB(0x17, 0x17, 0x17);
  191. borderColor = nvgRGB(0x5e, 0x5e, 0x5e);
  192. }
  193. };
  194. } // namespace rack