diff --git a/src/droplets/mixer_droplet.cpp b/src/droplets/mixer_droplet.cpp index a9a6403..1ac30cf 100644 --- a/src/droplets/mixer_droplet.cpp +++ b/src/droplets/mixer_droplet.cpp @@ -61,60 +61,40 @@ void MixerDroplet::Draw() { default: case DropletState::kFull: divider = (GetScreenMax()-GetScreenMin())/5.5; - DrawSolidRect(Patch(), - GetScreenMin(), - GetTitleHeight()*(1.0f-mix[0].Process()), - divider, - GetTitleHeight()-1, - true); - DrawSolidRect(Patch(), - GetScreenMin()+divider, - GetTitleHeight()*(1.0f-mix[1].Process()), - GetScreenMin()+divider*2, - GetTitleHeight()-1, - true); - DrawSolidRect(Patch(), - GetScreenMax()-divider*2, - GetTitleHeight()*(1.0f-mix[2].Process()), - GetScreenMax()-divider, - GetTitleHeight()-1, - true); - DrawSolidRect(Patch(), - GetScreenMax()-divider, - GetTitleHeight()*(1.0f-mix[3].Process()), - GetScreenMax(), - GetTitleHeight()-1, - true); + DrawFourDividedRectangles(Patch(), + divider, + GetScreenMin(), + GetScreenMax(), + GetTitleHeight()*(1.0f-mix[0].Process()), + GetTitleHeight()-1, + GetTitleHeight()*(1.0f-mix[1].Process()), + GetTitleHeight()-1, + GetTitleHeight()*(1.0f-mix[2].Process()), + GetTitleHeight()-1, + GetTitleHeight()*(1.0f-mix[3].Process()), + GetTitleHeight()-1); break; case DropletState::kLeft: divider = (GetScreenMax()-GetScreenMin())/4.5; - DrawSolidRect(Patch(), - GetScreenMin(), - GetTitleHeight()*(1.0f-mix[0].Process()), - GetScreenMin()+divider, - GetTitleHeight()-1, - true); - DrawSolidRect(Patch(), - GetScreenMax()-divider, - GetTitleHeight()*(1.0f-mix[1].Process()), - GetScreenMax(), - GetTitleHeight()-1, - true); + DrawTwoDividedRectangles(Patch(), + divider, + GetScreenMin(), + GetScreenMax(), + GetTitleHeight()*(1.0f-mix[0].Process()), + GetTitleHeight()-1, + GetTitleHeight()*(1.0f-mix[1].Process()), + GetTitleHeight()-1); break; case DropletState::kRight: divider = (GetScreenMax()-GetScreenMin())/4.5; - DrawSolidRect(Patch(), - GetScreenMin(), - GetTitleHeight()*(1.0f-mix[2].Process()), - GetScreenMin()+divider, - GetTitleHeight()-1, - true); - DrawSolidRect(Patch(), - GetScreenMax()-divider, - GetTitleHeight()*(1.0f-mix[3].Process()), - GetScreenMax(), - GetTitleHeight()-1, - true); + DrawTwoDividedRectangles(Patch(), + divider, + GetScreenMin(), + GetScreenMax(), + GetTitleHeight()*(1.0f-mix[2].Process()), + GetTitleHeight()-1, + GetTitleHeight()*(1.0f-mix[3].Process()), + GetTitleHeight()-1); break; } DrawName("Mixer"); diff --git a/src/util.cpp b/src/util.cpp index 47a99b7..95dc4fc 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -127,9 +127,55 @@ std::string FloatToString(float num, int places) { return sign + std::to_string(integral) + "." + std::to_string(fractional); } +void DrawTwoDividedRectangles(DaisyPatch* patch, + int divider, + int width_min, + int width_max, + int rect_one_min, + int rect_one_max, + int rect_two_min, + int rect_two_max) { + DrawSolidRect(patch, + width_min, + rect_one_max, + width_min+divider, + rect_one_min, + true); + DrawSolidRect(patch, + width_max-divider, + rect_two_max, + width_max, + rect_two_min, + true); +} - - - - +void DrawFourDividedRectangles(DaisyPatch* patch, + int divider, + int width_min, + int width_max, + int rect_one_min, + int rect_one_max, + int rect_two_min, + int rect_two_max, + int rect_three_min, + int rect_three_max, + int rect_four_min, + int rect_four_max) { + DrawTwoDividedRectangles(patch, + divider, + width_min, + width_max, + rect_one_min, + rect_one_max, + rect_four_min, + rect_four_max); + DrawTwoDividedRectangles(patch, + divider, + width_min+divider, + width_max-divider, + rect_two_min, + rect_two_max, + rect_three_min, + rect_three_max); +} diff --git a/src/util.h b/src/util.h index 0252dd9..2f9a034 100644 --- a/src/util.h +++ b/src/util.h @@ -147,4 +147,54 @@ std::string WaveToString(uint8_t wf); */ std::string FloatToString(float num, int places); +/* + * Draws two rectangles on the left and right side of a given area. + * + * @param patch daisy patch board + * @param divider rectangle length + * @param width_min left edge of bounding box + * @param width_max right enge of bounding box + * @param rect_one_min first rectangle lowest edge + * @param rect_one_max first rectangle highest edge + * @param rect_two_min second rectangle lowest edge + * @param rect_two_max second rectangle highest edge + */ +void DrawTwoDividedRectangles(DaisyPatch* patch, + int divider, + int width_min, + int width_max, + int rect_one_min, + int rect_one_max, + int rect_two_min, + int rect_two_max); + +/* + * Draws four rectangles on the left and right side of a given area. + * + * @param patch daisy patch board + * @param divider rectangle length + * @param width_min left edge of bounding box + * @param width_max right enge of bounding box + * @param rect_one_min first rectangle lowest edge + * @param rect_one_max first rectangle highest edge + * @param rect_two_min second rectangle lowest edge + * @param rect_two_max second rectangle highest edge + * @param rect_one_min third rectangle lowest edge + * @param rect_one_max third rectangle highest edge + * @param rect_two_min forth rectangle lowest edge + * @param rect_two_max forth rectangle highest edge + */ +void DrawFourDividedRectangles(DaisyPatch* patch, + int divider, + int width_min, + int width_max, + int rect_one_min, + int rect_one_max, + int rect_two_min, + int rect_two_max, + int rect_three_min, + int rect_three_max, + int rect_four_min, + int rect_four_max); + #endif // CASCADE_UTIL_H_