Skip to content

Commit

Permalink
makeDetailsMask() "maxBlanks" temp var
Browse files Browse the repository at this point in the history
  • Loading branch information
Explorer09 committed Feb 10, 2024
1 parent 195717e commit 363edd3
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions Meter.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,7 @@ static uint16_t GraphMeterMode_makeDetailsMask(const GraphColorComputeState* pre
assert(rem >= 0.0);
assert(rem < 1.0);

// If "rem" is not zero, it should have a minimum value so that
// (1.0 - rem) will not round to 1.0.
assert(rem <= 0.0 || rem >= (1.0 / UINT8_MAX));
double maxBlanks = (1.0 - rem) * 8.0;

uint8_t blanksAtEnd;
bool roundsUpInAscii = false;
Expand All @@ -515,14 +513,13 @@ static uint16_t GraphMeterMode_makeDetailsMask(const GraphColorComputeState* pre
blanksAtEnd = (uint8_t)blanksAtTopCell;
roundsUpInAscii = true;
} else if (prev->nCellsPainted == 0 || prev->topPoint <= prev->nCellsPainted) {
blanksAtEnd = (uint8_t)((1.0 - rem) * 8.0) % 8;
blanksAtEnd = (uint8_t)maxBlanks % 8;
} else if (new->nCellsPainted > new->topPoint) {
assert(new->nCellsPainted - new->topPoint < 1.0);
// Unlike other conditions, this one rounds to nearest for visual reason.
// In case of a tie, display the dot at lower position of the graph,
// i.e. MSB of the "details" data.
double fraction = (1.0 - rem) * 8.0;
fraction -= (int)fraction;
double fraction = maxBlanks - (int)maxBlanks;
double distance = (new->nCellsPainted - new->topPoint) * 8.0 + (1.0 - fraction) * 0.5;
blanksAtEnd = (uint8_t)distance;

Expand All @@ -539,7 +536,7 @@ static uint16_t GraphMeterMode_makeDetailsMask(const GraphColorComputeState* pre

uint8_t blanksAtStart;
if (prev->nCellsPainted > 0) {
blanksAtStart = (uint8_t)((int)((1.0 - rem) * 8.0) - blanksAtEnd) % 8;
blanksAtStart = (uint8_t)((int)maxBlanks - blanksAtEnd) % 8;
} else {
// Always zero blanks for the first cell.
// When an item would be painted with all cells (from the first cell to
Expand Down

0 comments on commit 363edd3

Please sign in to comment.