SmartGuitarAmp

Guitar plugin made with JUCE that uses neural networks to emulate a tube amplifier
Log | Files | Refs | Submodules | README

myLookAndFeel.cpp (1594B)


      1 /*
      2   ==============================================================================
      3 
      4     Created: 14 Dec 2017 10:16:04am
      5     Author:  Stefan Remberg
      6 
      7     Modified by keyth72
      8 
      9   ==============================================================================
     10 */
     11 
     12 #include "myLookAndFeel.h"
     13 
     14 //==============================================================================
     15 myLookAndFeel::myLookAndFeel()
     16 {
     17 }
     18 
     19 //==============================================================================
     20 void myLookAndFeel::setLookAndFeel(Image inputImage)
     21 {
     22     // Edit this line to match png file from project Resources
     23     img = inputImage;
     24 }
     25 
     26 
     27 //==============================================================================
     28 void myLookAndFeel::drawRotarySlider(Graphics& g,
     29     int x, int y, int width, int height, float sliderPos,
     30     float rotaryStartAngle, float rotaryEndAngle, Slider& slider)
     31 {
     32     const double rotation = (slider.getValue()
     33         - slider.getMinimum())
     34         / (slider.getMaximum()
     35             - slider.getMinimum());
     36 
     37     const int frames = img.getHeight() / img.getWidth();
     38     const int frameId = (int)ceil(rotation * ((double)frames - 1.0));
     39     const float radius = jmin(width / 2.0f, height / 2.0f);
     40     const float centerX = x + width * 0.5f;
     41     const float centerY = y + height * 0.5f;
     42     const float rx = centerX - radius - 1.0f;
     43     const float ry = centerY - radius;
     44 
     45     g.drawImage(img,
     46         (int)rx,
     47         (int)ry,
     48         2 * (int)radius,
     49         2 * (int)radius,
     50         0,
     51         frameId*img.getWidth(),
     52         img.getWidth(),
     53         img.getWidth());
     54 }