#pragma once #include #include #include #include #include namespace Amuencha { using namespace boost::math::float_constants; using namespace std; struct SpiralDisplay { static consteval int width() { return 400; } static consteval int height() { return 400; } // Cannot intialize note_positions array with consteval, as polar is not consterpx // static consteval const array, 12> init_pos() // { // return [] (index_sequence) // -> array, 12> // { return { polar(0.9f, half_pi - I * two_pi/12) ... }; } // (make_index_sequence<12>{}); // } // static const constexpr array, 12> note_positions{inti_pos()}; array, 12> note_positions{}; SpiralDisplay() { for (int i{0}; i < 12; i++) note_positions[i] = polar(.80f, half_pi - i * two_pi / 12); } static const constexpr string_view note_names[12] {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"}; float half; float x(float x) const { return half + x * half; } float y(float y) const { return half - y * half; } void paint(avnd::painter auto ctx) { half = height() * .5f; for (int i{0}; i < 12; i++) { ctx.move_to(half, half); ctx.line_to(x(note_positions[i].real()), y(note_positions[i].imag())); ctx.draw_text(x(note_positions[i].real() * 1.1 - .02), y(note_positions[i].imag() * 1.1 - .01), note_names[i]); } ctx.stroke(); } }; }