This VU-Meter consits of 48 font glyphs. Each single polygon is represented by a letter in a font. This method makes it possible to create complex graphic elements in InkScape on one hand, and on the other hand it makes it possible to declare the color and/or appearance of each polygon dynamically by a few lines of code.
nvgFontFaceId(disp.vg, vuMeterFont->handle);
nvgFontSize(disp.vg, 36);
textPos = Vec(2, 19.5);
for (auto i = 0; i < 24; ++i) {
if (i > 15) {
nvgFillColor(disp.vg, nvgRGB(0xff, 0x00, 0x00));
} else if (i > 7) {
nvgFillColor(disp.vg, textColorLight);
} else {
nvgFillColor(disp.vg, textColorDark);
}
if (i == needle) {
nvgFillColor(disp.vg, COLOR_WHITE);
}
nvgText(disp.vg, textPos.x, textPos.y, std::string(1, 97 + i).c_str(), NULL);
}
nvgFillColor(disp.vg, COLOR_WHITE);
nvgText(disp.vg, textPos.x, textPos.y, std::string(1, 65 + needle).c_str(), NULL);
That’s pretty cool. One could also make the entire VU and SVG and then programmatically color the different section for the same effect, yes? What are the pros and cons of using a font like this vs. manipulating an SVG?
I haven’t tried manipulating SVG graphics programmatically, so I can’t tell the differences.
Building a font seemed an easy way for me to declare a polygon or even a group of polygons as a glyph that can be easily accessed by specifying the ASCII code for the glyph.
Heh heh… I don’t care how you do it, as long as I can use your scopes. Just the other week I used envelope scope to “prove” that there was an omission in the SFZ spec.