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.

213 lines
4.5KB

  1. #pragma once
  2. #include "scene.hpp"
  3. namespace rack {
  4. #define SCHEME_BLACK nvgRGB(0x00, 0x00, 0x00)
  5. #define SCHEME_WHITE nvgRGB(0xff, 0xff, 0xff)
  6. #define SCHEME_RED nvgRGB(0xed, 0x2c, 0x24)
  7. #define SCHEME_ORANGE nvgRGB(0xf2, 0xb1, 0x20)
  8. #define SCHEME_YELLOW nvgRGB(0xf9, 0xdf, 0x1c)
  9. #define SCHEME_GREEN nvgRGB(0x90, 0xc7, 0x3e)
  10. #define SCHEME_CYAN nvgRGB(0x22, 0xe6, 0xef)
  11. #define SCHEME_BLUE nvgRGB(0x29, 0xb2, 0xef)
  12. #define SCHEME_PURPLE nvgRGB(0xd5, 0x2b, 0xed)
  13. ////////////////////
  14. // Knobs
  15. ////////////////////
  16. struct KnobDavies1900h : SpriteKnob {
  17. KnobDavies1900h() {
  18. box.size = Vec(36, 36);
  19. spriteOffset = Vec(-2, -2);
  20. spriteSize = Vec(42, 42);
  21. minIndex = 44;
  22. maxIndex = -46;
  23. spriteCount = 120;
  24. }
  25. };
  26. struct KnobDavies1900hWhite : KnobDavies1900h {
  27. KnobDavies1900hWhite() {
  28. spriteImage = Image::load("res/ComponentLibrary/Davies1900hWhite.png");
  29. }
  30. };
  31. struct KnobDavies1900hBlack : KnobDavies1900h {
  32. KnobDavies1900hBlack() {
  33. spriteImage = Image::load("res/ComponentLibrary/Davies1900hBlack.png");
  34. }
  35. };
  36. struct KnobDavies1900hRed : KnobDavies1900h {
  37. KnobDavies1900hRed() {
  38. spriteImage = Image::load("res/ComponentLibrary/Davies1900hRed.png");
  39. }
  40. };
  41. struct BefacoBigKnob : SpriteKnob {
  42. BefacoBigKnob() {
  43. box.size = Vec(75, 75);
  44. spriteOffset = Vec(-2, -2);
  45. spriteSize = Vec(81, 81);
  46. minIndex = 44;
  47. maxIndex = -46;
  48. spriteCount = 120;
  49. spriteImage = Image::load("res/ComponentLibrary/BefacoBigKnob.png");
  50. }
  51. };
  52. struct BefacoTinyKnob : SpriteKnob {
  53. BefacoTinyKnob() {
  54. box.size = Vec(26, 26);
  55. spriteOffset = Vec(-2, -2);
  56. spriteSize = Vec(32, 32);
  57. minIndex = 44;
  58. maxIndex = -46;
  59. spriteCount = 120;
  60. spriteImage = Image::load("res/ComponentLibrary/BefacoTinyKnob.png");
  61. }
  62. };
  63. struct BefacoSlidePot : SpriteKnob {
  64. BefacoSlidePot() {
  65. box.size = Vec(12, 122);
  66. spriteOffset = Vec(-2, -6);
  67. spriteSize = Vec(18, 134);
  68. minIndex = 97;
  69. maxIndex = 0;
  70. spriteCount = 98;
  71. spriteImage = Image::load("res/ComponentLibrary/BefacoSlidePot.png");
  72. }
  73. };
  74. ////////////////////
  75. // Jacks
  76. ////////////////////
  77. template <typename BASE>
  78. struct PJ301M : BASE {
  79. PJ301M() {
  80. this->box.size = Vec(24, 24);
  81. this->spriteOffset = Vec(-2, -2);
  82. this->spriteSize = Vec(30, 30);
  83. this->spriteImage = Image::load("res/ComponentLibrary/PJ301M.png");
  84. }
  85. };
  86. typedef PJ301M<InputPort> InputPortPJ301M;
  87. typedef PJ301M<OutputPort> OutputPortPJ301M;
  88. template <typename BASE>
  89. struct PJ3410 : BASE {
  90. PJ3410() {
  91. this->box.size = Vec(32, 32);
  92. this->spriteOffset = Vec(-1, -1);
  93. this->spriteSize = Vec(36, 36);
  94. this->spriteImage = Image::load("res/ComponentLibrary/PJ3410.png");
  95. }
  96. };
  97. typedef PJ3410<InputPort> InputPortPJ3410;
  98. typedef PJ3410<OutputPort> OutputPortPJ3410;
  99. template <typename BASE>
  100. struct CL1362 : BASE {
  101. CL1362() {
  102. this->box.size = Vec(33, 29);
  103. this->spriteOffset = Vec(-2, -2);
  104. this->spriteSize = Vec(39, 36);
  105. this->spriteImage = Image::load("res/ComponentLibrary/CL1362.png");
  106. }
  107. };
  108. typedef CL1362<InputPort> InputPortCL1362;
  109. typedef CL1362<OutputPort> OutputPortCL1362;
  110. ////////////////////
  111. // Lights
  112. ////////////////////
  113. struct ValueLight : Light {
  114. float *value;
  115. };
  116. struct RedValueLight : ValueLight {
  117. void step() {
  118. float v = sqrtBipolar(getf(value));
  119. color = nvgLerpRGBA(SCHEME_BLACK, SCHEME_RED, v);
  120. }
  121. };
  122. struct GreenRedPolarityLight : ValueLight {
  123. void step() {
  124. float v = sqrtBipolar(getf(value));
  125. if (v >= 0.0)
  126. color = nvgLerpRGBA(SCHEME_BLACK, SCHEME_GREEN, v);
  127. else
  128. color = nvgLerpRGBA(SCHEME_BLACK, SCHEME_RED, -v);
  129. }
  130. };
  131. template <typename BASE>
  132. struct LargeLight : BASE {
  133. LargeLight() {
  134. this->box.size = Vec(20, 20);
  135. }
  136. };
  137. template <typename BASE>
  138. struct MediumLight : BASE {
  139. MediumLight() {
  140. this->box.size = Vec(12, 12);
  141. }
  142. };
  143. template <typename BASE>
  144. struct SmallLight : BASE {
  145. SmallLight() {
  146. this->box.size = Vec(8, 8);
  147. }
  148. };
  149. ////////////////////
  150. // Misc
  151. ////////////////////
  152. /** If you don't add these to your ModuleWidget, it will fall out of the rack... */
  153. struct Screw : SpriteWidget {
  154. Screw() {
  155. box.size = Vec(15, 14);
  156. spriteOffset = Vec(0, 0);
  157. spriteSize = Vec(15, 14);
  158. }
  159. };
  160. struct BlackScrew : Screw {
  161. BlackScrew() {
  162. spriteImage = Image::load("res/ComponentLibrary/ScrewBlack.png");
  163. }
  164. };
  165. struct SilverScrew : Screw {
  166. SilverScrew() {
  167. spriteImage = Image::load("res/ComponentLibrary/ScrewSilver.png");
  168. }
  169. };
  170. struct LightPanel : Panel {
  171. LightPanel() {
  172. backgroundColor = nvgRGB(0xe8, 0xe8, 0xe8);
  173. borderColor = nvgRGB(0xac, 0xac, 0xac);
  174. }
  175. };
  176. struct DarkPanel : Panel {
  177. DarkPanel() {
  178. backgroundColor = nvgRGB(0x0f, 0x0f, 0x0f);
  179. borderColor = nvgRGB(0x5e, 0x5e, 0x5e);
  180. }
  181. };
  182. } // namespace rack