Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
e2fde830
Commit
e2fde830
authored
Dec 24, 2015
by
Explorer09
Browse files
Fix graph coloring algorithm (again, this time I get it right).
parent
360ffbb6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Meter.c
View file @
e2fde830
...
...
@@ -435,10 +435,12 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
double
maxArea
=
0
.
0
;
for
(
int
i
=
0
;
i
<
items
;
i
++
)
{
double
area
;
area
=
MIN
(
currentItemSums
[
i
],
this
->
total
*
(
GRAPH_HEIGHT
-
line
)
/
GRAPH_HEIGHT
)
+
MIN
(
prevItemSums
[
i
],
this
->
total
*
(
GRAPH_HEIGHT
-
line
)
/
GRAPH_HEIGHT
);
area
-=
MAX
(((
i
>
0
)
?
currentItemSums
[
i
-
1
]
:
0
),
this
->
total
*
(
GRAPH_HEIGHT
-
1
-
line
)
/
GRAPH_HEIGHT
)
+
MAX
(((
i
>
0
)
?
currentItemSums
[
i
-
1
]
:
0
),
this
->
total
*
(
GRAPH_HEIGHT
-
1
-
line
)
/
GRAPH_HEIGHT
);
double
upperBound
=
this
->
total
*
(
GRAPH_HEIGHT
-
line
)
/
GRAPH_HEIGHT
;
double
lowerBound
=
this
->
total
*
(
GRAPH_HEIGHT
-
1
-
line
)
/
GRAPH_HEIGHT
;
area
=
MAX
(
lowerBound
,
MIN
(
currentItemSums
[
i
],
upperBound
))
+
MAX
(
lowerBound
,
MIN
(
prevItemSums
[
i
],
upperBound
));
area
-=
MAX
(
lowerBound
,
MIN
(((
i
>
0
)
?
currentItemSums
[
i
-
1
]
:
0
),
upperBound
))
+
MAX
(
lowerBound
,
MIN
(((
i
>
0
)
?
prevItemSums
[
i
-
1
]
:
0
),
upperBound
));
if
(
area
>
maxArea
)
{
maxArea
=
area
;
dominantColor
=
CRT_colors
[
Meter_attributes
(
this
)[
i
]];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment