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.

common.hpp 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. #include "../common.hpp"
  3. #include "math.hpp"
  4. #include <jansson.h>
  5. namespace rack {
  6. /** Rack-specific GUI widgets and functions that control and offer feedback for the rack state.
  7. */
  8. namespace app {
  9. static const char APP_NAME[] = "VCV Rack";
  10. static const char APP_VERSION[] = TOSTRING(VERSION);
  11. static const char API_URL[] = "https://api.vcvrack.com";
  12. static const float SVG_DPI = 75.0;
  13. static const float MM_PER_IN = 25.4;
  14. /** Converts inch measurements to pixels */
  15. inline float in2px(float in) {
  16. return in * SVG_DPI;
  17. }
  18. inline math::Vec in2px(math::Vec in) {
  19. return in.mult(SVG_DPI);
  20. }
  21. /** Converts millimeter measurements to pixels */
  22. inline float mm2px(float mm) {
  23. return mm * (SVG_DPI / MM_PER_IN);
  24. }
  25. inline math::Vec mm2px(math::Vec mm) {
  26. return mm.mult(SVG_DPI / MM_PER_IN);
  27. }
  28. // A 1HPx3U module should be 15x380 pixels. Thus the width of a module should be a factor of 15.
  29. static const float RACK_GRID_WIDTH = 15;
  30. static const float RACK_GRID_HEIGHT = 380;
  31. static const math::Vec RACK_GRID_SIZE = math::Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT);
  32. static const math::Vec RACK_OFFSET = RACK_GRID_SIZE.mult(math::Vec(2000, 100));
  33. static const math::Vec BUS_BOARD_GRID_SIZE = math::Vec(RACK_GRID_WIDTH * 20, RACK_GRID_HEIGHT);
  34. } // namespace app
  35. } // namespace rack