Free Knob Textures

I suppose what I meant is that the shadow is drawn typically in SvgKnob.hpp. Knobs that inherit from SvgKnob get a “free” shadow without having to implement it directly in the SVG.

  struct SvgKnob : Knob {
      widget::FramebufferWidget* fb;
      CircularShadow* shadow;       // ← the shadow
      widget::TransformWidget* tw;  // rotates with value
      widget::SvgWidget* sw;        // the knob face SVG
  };

For example, this knob was exported from the knob designer without a shadow, but Rack added it in automatically:

So, when Kirkwoodwest said…

… it was a bit confusing to me, because it should be unnecessary to create the shadow from within my knob designer software since it’s added by rack automatically. Just clarifying things!

I believe you’re both correct. I shouldn’t have removed my earlier post- many knobs in the standard library have a shading layer that doesn’t rotate. You can do this yourself- just pull in the library’s and add your own knob. Replace one of these SVGs:

struct MyKnobBasedOnRoundBlackKnob : RoundKnob {
	MyKnobBasedOnRoundBlackKnob() {
		setSvg(Svg::load(asset::system("res/ComponentLibrary/RoundBlackKnob.svg")));
		bg->setSvg(Svg::load(asset::system("res/ComponentLibrary/RoundBlackKnob_bg.svg")));
	}
};

Thank you @brer_rabbit ,

I might have mentioned this before, but since we’re talking about custom knob code, it’s noteworthy that the knob editor allows you to export a C++ file with the knob’s code so you don’t have to write it yourself:

4 Likes

That’s quite slick looking at the download from your tool. I’m certainly not telling you anything new here, looks like it’s well thought through!

1 Like

Thank you!! I appreciate you taking the time to share knowledge. I try to do the same thing when I have a chance. :man_bowing:

1 Like