Skip to content

Commit

Permalink
Tighten the criterion for rectangle line-sameness
Browse files Browse the repository at this point in the history
  • Loading branch information
baskerville authored and LinusCDE committed Apr 20, 2021
1 parent 1ffcff7 commit 5e8c3df
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/view/reader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2711,7 +2711,8 @@ impl View for Reader {
let mut rect = rects[i].0;
while rects[i].1 < start_high {
let next_rect = rects[i+1].0;
if rect.min.y < next_rect.max.y && next_rect.min.y < rect.max.y {
if rect.max.y.min(next_rect.max.y) - rect.min.y.max(next_rect.min.y) >
rect.height().min(next_rect.height()) as i32 / 2 {
if rects[i+1].1 == start_high {
if rect.min.x < next_rect.min.x {
rect.max.x = next_rect.min.x;
Expand All @@ -2738,7 +2739,8 @@ impl View for Reader {
let mut rect = rects[i].0;
while rects[i].1 > end_low {
let prev_rect = rects[i-1].0;
if rect.min.y < prev_rect.max.y && prev_rect.min.y < rect.max.y {
if rect.max.y.min(prev_rect.max.y) - rect.min.y.max(prev_rect.min.y) >
rect.height().min(prev_rect.height()) as i32 / 2 {
if rects[i-1].1 == end_low {
if rect.min.x > prev_rect.min.x {
rect.min.x = prev_rect.max.x;
Expand Down Expand Up @@ -3691,7 +3693,8 @@ impl View for Reader {
fb.invert_region(search_rect);
}
if let Some(last) = last_rect {
if rect.min.y < last.max.y && last.min.y < rect.max.y && (last.max.x < rect.min.x || rect.max.x < last.min.x) {
if rect.max.y.min(last.max.y) - rect.min.y.max(last.min.y) > rect.height().min(last.height()) as i32 / 2 &&
(last.max.x < rect.min.x || rect.max.x < last.min.x) {
let space = if last.max.x < rect.min.x {
rect![last.max.x, (last.min.y + rect.min.y) / 2,
rect.min.x, (last.max.y + rect.max.y) / 2]
Expand Down Expand Up @@ -3721,7 +3724,9 @@ impl View for Reader {
fb.shift_region(sel_rect, drift);
}
if let Some(last) = last_rect {
if rect.min.y < last.max.y && last.min.y < rect.max.y && (last.max.x < rect.min.x || rect.max.x < last.min.x) {
// Are `rect` and `last` on the same line?
if rect.max.y.min(last.max.y) - rect.min.y.max(last.min.y) > rect.height().min(last.height()) as i32 / 2 &&
(last.max.x < rect.min.x || rect.max.x < last.min.x) {
let space = if last.max.x < rect.min.x {
rect![last.max.x, (last.min.y + rect.min.y) / 2,
rect.min.x, (last.max.y + rect.max.y) / 2]
Expand Down Expand Up @@ -3749,7 +3754,8 @@ impl View for Reader {
fb.invert_region(sel_rect);
}
if let Some(last) = last_rect {
if rect.min.y < last.max.y && last.min.y < rect.max.y && (last.max.x < rect.min.x || rect.max.x < last.min.x) {
if rect.max.y.min(last.max.y) - rect.min.y.max(last.min.y) > rect.height().min(last.height()) as i32 / 2 &&
(last.max.x < rect.min.x || rect.max.x < last.min.x) {
let space = if last.max.x < rect.min.x {
rect![last.max.x, (last.min.y + rect.min.y) / 2,
rect.min.x, (last.max.y + rect.max.y) / 2]
Expand Down

0 comments on commit 5e8c3df

Please sign in to comment.