-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpinningDial.cpp
More file actions
29 lines (23 loc) · 810 Bytes
/
SpinningDial.cpp
File metadata and controls
29 lines (23 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "SpinningDial.h"
SpinningDial::SpinningDial() : angle(0.0f) {}
void SpinningDial::paint(juce::Graphics& g)
{
auto bounds = getLocalBounds().toFloat();
auto center = bounds.getCentre();
float radius = juce::jmin(bounds.getWidth(), bounds.getHeight()) / 2.0f;
g.setColour(juce::Colours::lightgrey);
g.fillEllipse(center.x - radius, center.y - radius, 2.0f * radius, 2.0f * radius);
juce::Line<float> line(
center.y + radius * 0.6f * std::sin(angle),
center.x + radius * 0.6f * std::cos(angle),
center.y - radius * 0.9f * std::sin(angle),
center.x - radius * 0.9f * std::cos(angle)
);
g.setColour(juce::Colours::black);
g.drawLine(line, 1.0f);
}
void SpinningDial::setAngle(float newAngle)
{
angle = newAngle;
repaint();
}