Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/extract/src/rect.c @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 #include "extract/extract.h" | |
| 2 #include "document.h" | |
| 3 | |
| 4 static inline double | |
| 5 mind(double a, double b) | |
| 6 { | |
| 7 return (a < b) ? a : b; | |
| 8 } | |
| 9 | |
| 10 static inline double | |
| 11 maxd(double a, double b) | |
| 12 { | |
| 13 return (a > b) ? a : b; | |
| 14 } | |
| 15 | |
| 16 rect_t extract_rect_intersect(rect_t a, rect_t b) | |
| 17 { | |
| 18 rect_t r; | |
| 19 | |
| 20 r.min.x = maxd(a.min.x, b.min.x); | |
| 21 r.min.y = maxd(a.min.y, b.min.y); | |
| 22 r.max.x = mind(a.max.x, b.max.x); | |
| 23 r.max.y = mind(a.max.y, b.max.y); | |
| 24 | |
| 25 return r; | |
| 26 } | |
| 27 | |
| 28 rect_t extract_rect_union(rect_t a, rect_t b) | |
| 29 { | |
| 30 rect_t r; | |
| 31 | |
| 32 r.min.x = mind(a.min.x, b.min.x); | |
| 33 r.min.y = mind(a.min.y, b.min.y); | |
| 34 r.max.x = maxd(a.max.x, b.max.x); | |
| 35 r.max.y = maxd(a.max.y, b.max.y); | |
| 36 | |
| 37 return r; | |
| 38 } | |
| 39 | |
| 40 rect_t extract_rect_union_point(rect_t a, point_t b) | |
| 41 { | |
| 42 rect_t r; | |
| 43 | |
| 44 r.min.x = mind(a.min.x, b.x); | |
| 45 r.min.y = mind(a.min.y, b.y); | |
| 46 r.max.x = maxd(a.max.x, b.x); | |
| 47 r.max.y = maxd(a.max.y, b.y); | |
| 48 | |
| 49 return r; | |
| 50 } | |
| 51 | |
| 52 int extract_rect_contains_rect(rect_t a, rect_t b) | |
| 53 { | |
| 54 if (a.min.x > b.min.x) | |
| 55 return 0; | |
| 56 if (a.min.y > b.min.y) | |
| 57 return 0; | |
| 58 if (a.max.x < b.max.x) | |
| 59 return 0; | |
| 60 if (a.max.y < b.max.y) | |
| 61 return 0; | |
| 62 | |
| 63 return 1; | |
| 64 } | |
| 65 | |
| 66 int extract_rect_valid(rect_t a) | |
| 67 { | |
| 68 return (a.min.x <= a.max.x && a.min.y <= a.max.y); | |
| 69 } |
