In what ways will Rack v2 require the use of "mm" units for drawing?

I’ve seen a few discussions suggesting that mm units will be required for module panels in Rack v2. What I’m wondering is:

  1. Will existing .svg files that define panel backgrounds, knobs, etc. need to be converted so that the .svg source code uses mm units?
  2. Will existing ModuleWidget or other custom widget code need to be converted so that components are placed using mm units?
  3. Is there any other unit conversion type stuff that module creators/maintainers will have to do for Rack v2?

Tagging @Vortico because I think he’s the only person who can answer :slight_smile:

1 Like

No to all questions.

However, when creating new modules, use millimeters. This is because VCV Rack will always use 128.5mm tall rows. All graphics are vector, so you shouldn’t think in pixels at all. The actual number of screen pixels in a nanovg “pixel” depends on the rack’s zoom level and the OS’s zoom level (for high-DPI screens). Use mm2px() to convert from mm to nanovg pixels in code.

2 Likes

I never use mm2px and only place things in terms pixels but everything looks the same no matter the zoom level. When could not using mm2px lead to wrongly sized/placed widgets?

It will not. Pixels are just a weird unit, defined by VCV Rack as 1/75 inches, or 0.338(6) mm.

I see, I’m relieved then. :slight_smile:

But isn’t a 128.5mm grid height just as weird as a 380 pixels one?

I guess the connection to the real world makes it less weird, but for me it would be more hassle to use mm2px everywhere than how much it helps me to think in terms of “real scale”.

No, 128.5 mm is the height of Eurorack modules. 380 pixels is an arbitrary decision made by me in 2016.

Yes, I understand. At this point I’m more familiar with your arbitrary decision than Eurorack size since I don’t own any hardware modules.

1 Like

I tried to use mm for all dimensions within my code but I failed at one place.

When setting the module size I can only use Pixel.

struct MyModuleWidget : ModuleWidget
{
	MyModuleWidget(MyModule *module)
	{
		setModule(module);

		// * Layer: Backplate
		//box.size = rack::Vec(120, 380); // <-- OK
		box.size = mm2px(rack::Vec(40.64, 128.5)); // <-- not working

The only way to make it work is using module height of 380 (Pixel). Is this intended or is there a way to use mm also in this case?

It doesn’t quite answer your question, but I usually go with
Vec(RACK_GRID_WIDTH * w, RACK_GRID_HEIGHT)
where w is an integer to make sure the module’s width is a multiple of the rail’s grid size.

I’m guessing the intended way would be to use an SVG for the panel with the right size settings instead of setting the box manually.

Thanks for your input. I am actually doing it also the way you described, but for sake of simplicity I have used the absolute values.