35 lines
1.3 KiB
C++
35 lines
1.3 KiB
C++
/*
|
|
==============================================================================
|
|
|
|
Dial.cpp
|
|
Created: 16 Jan 2026 7:16:39pm
|
|
Author: esca
|
|
|
|
==============================================================================
|
|
*/
|
|
|
|
#include "DialLook.h"
|
|
#include "BinaryData.h"
|
|
#include "juce_graphics/juce_graphics.h"
|
|
void DialLook::drawRotarySlider(juce::Graphics& g, int x, int y, int width, int height, float sliderPos, const float rotaryStartAngle, const float rotaryEndAngle, juce::Slider&){
|
|
|
|
auto radius = (float) juce::jmin (width / 2, height / 2) - 4.0f;
|
|
auto centreX = (float) x + (float) width * 0.5f;
|
|
auto centreY = (float) y + (float) height * 0.5f;
|
|
auto rx = centreX - radius;
|
|
auto ry = centreY - radius;
|
|
auto rw = radius * 2.0f;
|
|
auto angle = rotaryStartAngle + sliderPos * (rotaryEndAngle - rotaryStartAngle);
|
|
|
|
//background
|
|
g.drawImage(bgImg, x, y, width, height, 0, 0, 55, 56);
|
|
|
|
//rotator
|
|
g.drawImageTransformed(rotator, juce::AffineTransform::translation(-3, -2).rotated(angle+3.141f).translated(centreX, centreY), false);
|
|
}
|
|
|
|
void DialLook::setImage(){
|
|
bgImg = juce::ImageCache::getFromMemory(BinaryData::dialbg_png, BinaryData::dialbg_pngSize);
|
|
rotator = juce::ImageCache::getFromMemory(BinaryData::rotator_png, BinaryData::rotator_pngSize);
|
|
}
|