Cleaned code

This commit is contained in:
Christian Colglazier 2020-09-26 15:33:02 -04:00
parent b04fdf7f70
commit a351030fe4
4 changed files with 8 additions and 9 deletions

View File

@ -56,7 +56,6 @@ void VCODroplet::Draw() {
if(NeedUpdate()) { if(NeedUpdate()) {
wave->AdjustXShift(1); wave->AdjustXShift(1);
} }
//testWave->DrawTile(*Patch(), 0, GetTitleHeight(), 60, GetTitleHeight()+testH);
DrawName("VCO"); DrawName("VCO");
AnimationInc(); AnimationInc();
} }

View File

@ -22,10 +22,7 @@ private:
std::string WaveToString(uint8_t); std::string WaveToString(uint8_t);
void SetWaveState(uint8_t); void SetWaveState(uint8_t);
const double pi = std::acos(-1); const double pi = std::acos(-1);
int sine_width = 21; Wave* wave = new Wave(WaveShape::kTriangle, 21, GetTitleHeight());
Wave* wave = new Wave(WaveShape::kTriangle, sine_width, GetTitleHeight());
int testH = 20;
//Wave* testWave = new Wave(WaveShape::kSaw, 30, testH);
public: public:
VCODroplet(DaisyPatch*, DropletState, float); VCODroplet(DaisyPatch*, DropletState, float);
~VCODroplet(); ~VCODroplet();

View File

@ -54,7 +54,6 @@ int Sprite::GetHeight() {
return height; return height;
} }
int Sprite::GetWidth() { int Sprite::GetWidth() {
return width; return width;
@ -117,7 +116,9 @@ void Sprite::AdjustYShift(int y) {
y_shift += y; y_shift += y;
} }
int Sprite::GetShiftArray(int pos, int shift, int array_size) { int Sprite::GetShiftArray(int pos,
int shift,
int array_size) {
return (array_size + ((pos + shift) % array_size)) % array_size; return (array_size + ((pos + shift) % array_size)) % array_size;
} }

View File

@ -1,6 +1,8 @@
#include "wave.h" #include "wave.h"
Wave::Wave(WaveShape m_wave, int width, int height) : Sprite(width, height) { Wave::Wave(WaveShape m_wave,
int width,
int height) : Sprite(width, height) {
wave = m_wave; wave = m_wave;
DrawShape(); DrawShape();
} }
@ -28,7 +30,7 @@ void Wave::DrawShape() {
case WaveShape::kSine: case WaveShape::kSine:
default: default:
for (int i = 0; i < GetWidth(); i++) { for (int i = 0; i < GetWidth(); i++) {
int pixel = (int) round(std::sin(2*pi*((double)(i%GetWidth())/GetWidth())) * (GetHeight()/2) + GetHeight()/2); int pixel = (int) round(std::sin(2*pi*((double)(i%x_max)/x_max)) * (y_max/2) + y_max/2);
AddPixel(i, pixel, true); AddPixel(i, pixel, true);
} }
return; return;