rio: rewrite better portion() function
This commit is contained in:
parent
f5d9b2222b
commit
082560fd5b
1 changed files with 7 additions and 8 deletions
|
@ -392,16 +392,15 @@ whichrect(Rectangle r, Point p, int which)
|
|||
int
|
||||
portion(int x, int lo, int hi)
|
||||
{
|
||||
int t;
|
||||
x -= lo;
|
||||
hi -= lo;
|
||||
t = min(20, max(1, hi/2));
|
||||
if(hi < t)
|
||||
return x > 0 ? 2 : 0;
|
||||
if(x < t)
|
||||
return 0;
|
||||
if(x > hi-t)
|
||||
return 2;
|
||||
if(x < hi/2){
|
||||
if(x < 20)
|
||||
return 0;
|
||||
} else {
|
||||
if(x > hi-20)
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue