summaryrefslogtreecommitdiff
path: root/platform/android/src/com/artifex/mupdf/fitz/Rect.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/src/com/artifex/mupdf/fitz/Rect.java')
-rw-r--r--platform/android/src/com/artifex/mupdf/fitz/Rect.java79
1 files changed, 79 insertions, 0 deletions
diff --git a/platform/android/src/com/artifex/mupdf/fitz/Rect.java b/platform/android/src/com/artifex/mupdf/fitz/Rect.java
new file mode 100644
index 00000000..eb9138cf
--- /dev/null
+++ b/platform/android/src/com/artifex/mupdf/fitz/Rect.java
@@ -0,0 +1,79 @@
+package com.artifex.mupdf.fitz;
+
+public class Rect
+{
+ public float x0;
+ public float y0;
+ public float x1;
+ public float y1;
+
+ public Rect(float x0, float y0, float x1, float y1)
+ {
+ this.x0 = x0;
+ this.y0 = y0;
+ this.x1 = x1;
+ this.y1 = y1;
+ }
+
+ public Rect(Rect r)
+ {
+ this.x0 = r.x0;
+ this.y0 = r.y0;
+ this.x1 = r.x1;
+ this.y1 = r.y1;
+ }
+
+ public Rect transform(Matrix tm)
+ {
+ float ax0 = x0 * tm.a;
+ float ax1 = x1 * tm.a;
+
+ if (ax0 > ax1)
+ {
+ float t = ax0;
+ ax0 = ax1;
+ ax1 = t;
+ }
+
+ float cy0 = y0 * tm.c;
+ float cy1 = y1 * tm.c;
+
+ if (cy0 > cy1)
+ {
+ float t = cy0;
+ cy0 = cy1;
+ cy1 = t;
+ }
+ ax0 += cy0 + tm.e;
+ ax1 += cy1 + tm.e;
+
+ float bx0 = x0 * tm.b;
+ float bx1 = x1 * tm.b;
+
+ if (bx0 > bx1)
+ {
+ float t = bx0;
+ bx0 = bx1;
+ bx1 = t;
+ }
+
+ float dy0 = y0 * tm.d;
+ float dy1 = y1 * tm.d;
+
+ if (dy0 > dy1)
+ {
+ float t = dy0;
+ dy0 = dy1;
+ dy1 = t;
+ }
+ bx0 += dy0 + tm.f;
+ bx1 += dy1 + tm.f;
+
+ x0 = ax0;
+ x1 = ax1;
+ y0 = bx0;
+ y1 = bx1;
+
+ return this;
+ }
+}