MCPcopy Create free account
hub / github.com/TheWaveWarden/odin2 / paint

Method paint

Source/gui/SpectrumDisplay.cpp:31–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31void SpectrumDisplay::paint(Graphics &g) {
32 SET_INTERPOLATION_QUALITY(g)
33
34#ifdef WTGEN
35 g.fillAll(getLookAndFeel().findColour(ResizableWindow::backgroundColourId)); // clear the background
36
37 g.setColour(Colours::grey);
38 g.drawRect(getLocalBounds(), 1); // draw an outline around the component
39 g.setColour(Colours::white);
40 /*
41 g.setFont (14.0f);
42 g.drawText ("LOWER WT: " + std::to_string(m_lower_wt) + "\nHIGHER WT:" +
43 std::to_string(m_higher_wt) + "\nINTERPOLATION: " +
44 std::to_string(m_interpolation), getLocalBounds(), Justification::centred,
45 true); // draw some placeholder text
46
47 */
48 if (m_position_left) {
49 float *spectrum_left = m_WT_container->m_fourier_coeffs[m_lower_wt][0];
50 float scale_left = m_WT_container->m_fourier_coeffs[m_lower_wt][1][0];
51 float *spectrum_right = m_WT_container->m_fourier_coeffs[m_higher_wt][0];
52 float scale_right = m_WT_container->m_fourier_coeffs[m_higher_wt][1][0];
53
54 float inverse_polation = 1.f - m_interpolation;
55
56 float height = WTDISPLAY_SIZE_Y;
57
58 for (int i = 1; i < WTDISPLAY_SIZE_X / SPECTRUM_LINE_WIDTH; ++i) {
59
60 float draw_value =
61 spectrum_left[i] * scale_left * inverse_polation + spectrum_right[i] * scale_right * m_interpolation;
62
63 draw_value = floatabs(draw_value);
64 draw_value = pow(draw_value, 0.5);
65
66 if (draw_value > 1) {
67 g.setColour(Colours::red);
68 } else {
69 g.setColour(Colours::white);
70 }
71
72 g.drawLine(WTDISPLAY_INLAY + (i)*SPECTRUM_LINE_WIDTH,
73 WTDISPLAY_INLAY + height - draw_value * height,
74 WTDISPLAY_INLAY + (i)*SPECTRUM_LINE_WIDTH,
75 WTDISPLAY_INLAY + height,
76 SPECTRUM_LINE_WIDTH - 0.2);
77 }
78
79 } else {
80 g.setColour(Colours::grey);
81 g.drawArrow(Line<float>(17, getHeight() / 2, 7, getHeight() / 2), 0, 30, 15);
82 }
83#endif
84}

Callers

nothing calls this directly

Calls 1

floatabsFunction · 0.85

Tested by

no test coverage detected