mirror of
https://github.com/AquaMorph/Droplets.git
synced 2025-07-10 05:32:01 +00:00
VCO title bar changes based on wave shape
This commit is contained in:
@ -20,7 +20,7 @@ Sprite::~Sprite() {
|
||||
}
|
||||
|
||||
void Sprite::AddPixel(int x, int y, bool solid) {
|
||||
sprite[x][y] = solid;
|
||||
sprite[x][height-y-1] = solid;
|
||||
}
|
||||
|
||||
void Sprite::AddLine(int x1,
|
||||
@ -65,7 +65,7 @@ void Sprite::Draw(DaisyPatch patch, int x, int y) {
|
||||
for (int h = 0; h < height; h++) {
|
||||
patch.display.DrawPixel(x+w, y+h,
|
||||
sprite[GetShiftArrayX(w)]
|
||||
[GetShiftArrayY(h)]);
|
||||
[GetShiftArrayY(height-h)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -79,10 +79,12 @@ void Sprite::DrawTile(DaisyPatch patch,
|
||||
int x_max = std::max(x1, x2);
|
||||
int y_min = std::min(y1, y2);
|
||||
int y_max = std::max(y1, y2);
|
||||
int x, y;
|
||||
for (int w = x_min; w < x_max; w++) {
|
||||
for (int h = y_min; h < y_max; h++) {
|
||||
patch.display.DrawPixel(w, h, sprite[GetShiftArrayX((w-x_min) % width)]
|
||||
[GetShiftArrayY((h-y_min+y_shift) % height)]);
|
||||
x = GetShiftArrayX((w-x_min) % width);
|
||||
y = GetShiftArrayY((h-y_min) % height);
|
||||
patch.display.DrawPixel(w, h, sprite[x][y]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,22 @@ Wave::Wave(WaveShape m_wave, int width, int height) : Sprite(width, height) {
|
||||
void Wave::DrawShape() {
|
||||
SetBlank();
|
||||
int mid = GetWidth()/2;
|
||||
int x_max = GetWidth()-1;
|
||||
int y_max = GetHeight()-1;
|
||||
switch(wave) {
|
||||
case WaveShape::kSaw:
|
||||
AddLine(0, 0, x_max, y_max, true);
|
||||
AddLine(x_max, y_max, x_max, 0, true);
|
||||
return;
|
||||
case WaveShape::kSquare:
|
||||
AddLine(0, 0, mid, 0, true);
|
||||
AddLine(mid, 0, mid, y_max, true);
|
||||
AddLine(mid, y_max, x_max, y_max, true);
|
||||
AddLine(GetWidth()-1, GetHeight()-1, GetWidth()-1, 0, true);
|
||||
return;
|
||||
case WaveShape::kTriangle:
|
||||
AddLine(0, GetHeight()+1, mid, 0, true);
|
||||
AddLine(mid, 0, GetWidth()+1, GetHeight(), true);
|
||||
AddLine(0, 0, mid, y_max, true);
|
||||
AddLine(mid, y_max, x_max, 0, true);
|
||||
return;
|
||||
case WaveShape::kSine:
|
||||
default:
|
||||
@ -22,3 +34,8 @@ void Wave::DrawShape() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void Wave::SetWaveShape(WaveShape m_wave) {
|
||||
wave = m_wave;
|
||||
DrawShape();
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ class Wave: public Sprite {
|
||||
void DrawShape();
|
||||
public:
|
||||
Wave(WaveShape, int, int);
|
||||
void SetWaveShape(WaveShape);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user