Divided rectangle utils

This commit is contained in:
Christian Colglazier 2021-11-25 20:03:36 -05:00
parent 09ab66cfb5
commit ecf2e62963
3 changed files with 128 additions and 52 deletions

View File

@ -61,60 +61,40 @@ void MixerDroplet::Draw() {
default: default:
case DropletState::kFull: case DropletState::kFull:
divider = (GetScreenMax()-GetScreenMin())/5.5; divider = (GetScreenMax()-GetScreenMin())/5.5;
DrawSolidRect(Patch(), DrawFourDividedRectangles(Patch(),
GetScreenMin(), divider,
GetTitleHeight()*(1.0f-mix[0].Process()), GetScreenMin(),
divider, GetScreenMax(),
GetTitleHeight()-1, GetTitleHeight()*(1.0f-mix[0].Process()),
true); GetTitleHeight()-1,
DrawSolidRect(Patch(), GetTitleHeight()*(1.0f-mix[1].Process()),
GetScreenMin()+divider, GetTitleHeight()-1,
GetTitleHeight()*(1.0f-mix[1].Process()), GetTitleHeight()*(1.0f-mix[2].Process()),
GetScreenMin()+divider*2, GetTitleHeight()-1,
GetTitleHeight()-1, GetTitleHeight()*(1.0f-mix[3].Process()),
true); GetTitleHeight()-1);
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);
break; break;
case DropletState::kLeft: case DropletState::kLeft:
divider = (GetScreenMax()-GetScreenMin())/4.5; divider = (GetScreenMax()-GetScreenMin())/4.5;
DrawSolidRect(Patch(), DrawTwoDividedRectangles(Patch(),
GetScreenMin(), divider,
GetTitleHeight()*(1.0f-mix[0].Process()), GetScreenMin(),
GetScreenMin()+divider, GetScreenMax(),
GetTitleHeight()-1, GetTitleHeight()*(1.0f-mix[0].Process()),
true); GetTitleHeight()-1,
DrawSolidRect(Patch(), GetTitleHeight()*(1.0f-mix[1].Process()),
GetScreenMax()-divider, GetTitleHeight()-1);
GetTitleHeight()*(1.0f-mix[1].Process()),
GetScreenMax(),
GetTitleHeight()-1,
true);
break; break;
case DropletState::kRight: case DropletState::kRight:
divider = (GetScreenMax()-GetScreenMin())/4.5; divider = (GetScreenMax()-GetScreenMin())/4.5;
DrawSolidRect(Patch(), DrawTwoDividedRectangles(Patch(),
GetScreenMin(), divider,
GetTitleHeight()*(1.0f-mix[2].Process()), GetScreenMin(),
GetScreenMin()+divider, GetScreenMax(),
GetTitleHeight()-1, GetTitleHeight()*(1.0f-mix[2].Process()),
true); GetTitleHeight()-1,
DrawSolidRect(Patch(), GetTitleHeight()*(1.0f-mix[3].Process()),
GetScreenMax()-divider, GetTitleHeight()-1);
GetTitleHeight()*(1.0f-mix[3].Process()),
GetScreenMax(),
GetTitleHeight()-1,
true);
break; break;
} }
DrawName("Mixer"); DrawName("Mixer");

View File

@ -127,9 +127,55 @@ std::string FloatToString(float num, int places) {
return sign + std::to_string(integral) + "." + std::to_string(fractional); 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);
}

View File

@ -147,4 +147,54 @@ std::string WaveToString(uint8_t wf);
*/ */
std::string FloatToString(float num, int places); 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_ #endif // CASCADE_UTIL_H_