out = new ArrayList<>(size());
+ for (int i = left; i <= right; i++)
+ {
+ out.add(new Point(x[i], y[i]));
+ }
+ return out;
+ }
+
+ public void copyTo(int[] xDest, int[] yDest, int offset)
+ {
+ System.arraycopy(x, left, xDest, offset, size());
+ System.arraycopy(y, left, yDest, offset, size());
+ }
+
+ public void appendTo(SimplePolygon other)
+ {
+ int size = size();
+ if (size <= 0)
+ {
+ return;
+ }
+ other.expandRight(size);
+ copyTo(other.x, other.y, other.right + 1);
+ other.right += size;
+ }
+
+ public void reverse()
+ {
+ int half = size() / 2;
+ for (int i = 0; i < half; i++)
+ {
+ int li = left + i;
+ int ri = right - i;
+ int tx = x[li];
+ int ty = y[li];
+ x[li] = x[ri];
+ y[li] = y[ri];
+ x[ri] = tx;
+ y[ri] = ty;
+ }
+ }
+
+ /**
+ * Clips the polygon with the passed convex polygon
+ */
+ public void intersectWithConvex(SimplePolygon convex)
+ {
+ // Sutherland-Hodgman
+ int[] tx = new int[size()];
+ int[] ty = new int[tx.length];
+
+ int cx1 = convex.x[convex.right];
+ int cy1 = convex.y[convex.right];
+ for (int ci = convex.left; ci <= convex.right; ci++)
+ {
+ if (size() < 3)
+ {
+ return;
+ }
+
+ int tRight = this.right;
+ int tLeft = this.left;
+
+ int[] tmpX = x;
+ int[] tmpY = y;
+
+ this.x = tx;
+ this.y = ty;
+ this.left = 0;
+ this.right = -1;
+ tx = tmpX;
+ ty = tmpY;
+
+ int cx2 = convex.x[ci];
+ int cy2 = convex.y[ci];
+
+ int tx1 = tx[tRight];
+ int ty1 = ty[tRight];
+
+ for (int ti = tLeft; ti <= tRight; ti++)
+ {
+ int tx2 = tx[ti];
+ int ty2 = ty[ti];
+
+ int p1 = (cx2 - cx1) * (ty1 - cy1) - (cy2 - cy1) * (tx1 - cx1);
+ int p2 = (cx2 - cx1) * (ty2 - cy1) - (cy2 - cy1) * (tx2 - cx1);
+
+ if (p1 < 0 && p2 < 0)
+ {
+ pushRight(tx2, ty2);
+ }
+ else if (p1 >= 0 != p2 >= 0)
+ {
+ long nota = cx1 * cy2 - cy1 * cx2;
+ long clue = tx1 * ty2 - ty1 * tx2;
+ long div = ((cx1 - cx2) * (ty1 - ty2) - (cy1 - cy2) * (tx1 - tx2));
+ pushRight((int) ((nota * (tx1 - tx2) - (cx1 - cx2) * clue) / div),
+ (int) ((nota * (ty1 - ty2) - (cy1 - cy2) * clue) / div));
+
+ if (p1 >= 0)
+ {
+ pushRight(tx2, ty2);
+ }
+ }
+
+ tx1 = tx2;
+ ty1 = ty2;
+ }
+
+ cx1 = cx2;
+ cy1 = cy2;
+ }
+ }
+
+ @Override
+ public Rectangle getBounds()
+ {
+ int
+ minX = Integer.MAX_VALUE,
+ minY = Integer.MAX_VALUE,
+ maxX = Integer.MIN_VALUE,
+ maxY = Integer.MIN_VALUE;
+
+ for (int i = left; i <= right; i++)
+ {
+ final int xs = x[i];
+ final int ys = y[i];
+
+ if (xs < minX)
+ {
+ minX = xs;
+ }
+ if (xs > maxX)
+ {
+ maxX = xs;
+ }
+ if (ys < minY)
+ {
+ minY = ys;
+ }
+ if (ys > maxY)
+ {
+ maxY = ys;
+ }
+ }
+
+ return new Rectangle(minX, minY, maxX - minX, maxY - minY);
+ }
+
+ @Override
+ public Rectangle2D getBounds2D()
+ {
+ Rectangle b = getBounds();
+ return new Rectangle2D.Float(b.x, b.y, b.width, b.height);
+ }
+
+ @Override
+ public boolean contains(double cx, double cy)
+ {
+ if (size() < 3)
+ {
+ return false;
+ }
+
+ return (crossings(cx, cy, false) & 1) != 0;
+ }
+
+ private int crossings(double cx, double cy, boolean swap)
+ {
+ int collisions = 0;
+
+ int[] x = this.x;
+ int[] y = this.y;
+ if (swap)
+ {
+ y = this.x;
+ x = this.y;
+ }
+
+ for (int x0 = x[right], y0 = y[right], x1, y1, i = left; i <= right; i++, x0 = x1, y0 = y1)
+ {
+ x1 = x[i];
+ y1 = y[i];
+
+ if (y0 == y1)
+ {
+ continue;
+ }
+
+ double dy0 = y0, dy1 = y1;
+
+ if (cy <= dy0 == cy <= dy1)
+ {
+ continue;
+ }
+
+ double dx0 = x0, dx1 = x1;
+
+ boolean left = cx < dx0;
+ if (left == cx < dx1)
+ {
+ if (!left)
+ {
+ collisions++;
+ }
+ continue;
+ }
+
+ if ((dx1 - dx0) * (cy - dy0) - (cx - dx0) * (dy1 - dy0) > 0 == dy0 > dy1)
+ {
+ collisions++;
+ }
+ }
+ return collisions;
+ }
+
+ @Override
+ public boolean contains(Point2D p)
+ {
+ return contains(p.getX(), p.getY());
+ }
+
+ @Override
+ public boolean intersects(double x0, double y0, double w, double h)
+ {
+ // this is horribly inefficient, but I don't think it will be called anywhere
+
+ double x1 = x0 + w;
+ double y1 = y0 + h;
+
+ return crossings(x0, y0, false) != crossings(x1, y0, false) // top
+ || crossings(x0, y1, false) != crossings(x1, y1, false) // bottom
+ || crossings(x0, y0, true) != crossings(x0, y1, true) // left
+ || crossings(x1, y0, true) != crossings(x1, y1, true); // right
+
+ }
+
+ @Override
+ public boolean intersects(Rectangle2D r)
+ {
+ return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight());
+ }
+
+ @Override
+ public boolean contains(double x, double y, double w, double h)
+ {
+ if (!getBounds().contains(x, y, w, h))
+ {
+ return false;
+ }
+
+ return !intersects(x, y, w, h);
+ }
+
+ @Override
+ public boolean contains(Rectangle2D r)
+ {
+ return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight());
+ }
+
+
+ @Override
+ public PathIterator getPathIterator(AffineTransform at)
+ {
+ if (at == null)
+ {
+ return new SimpleIterator();
+ }
+ return new TransformIterator(at);
+ }
+
+ @Override
+ public PathIterator getPathIterator(AffineTransform at, double flatness)
+ {
+ return getPathIterator(at);
+ }
+
+ private class SimpleIterator implements PathIterator
+ {
+ private int i = -1;
+
+ @Override
+ public int getWindingRule()
+ {
+ return WIND_EVEN_ODD;
+ }
+
+ @Override
+ public boolean isDone()
+ {
+ return size() == 0 || i > right;
+ }
+
+ @Override
+ public void next()
+ {
+ if (i == -1)
+ {
+ i = left;
+ }
+ else
+ {
+ i++;
+ }
+ }
+
+ @Override
+ public int currentSegment(float[] coords)
+ {
+ if (i == -1)
+ {
+ coords[0] = x[right];
+ coords[1] = y[right];
+ return SEG_MOVETO;
+ }
+
+ coords[0] = x[i];
+ coords[1] = y[i];
+ return SEG_LINETO;
+ }
+
+ @Override
+ public int currentSegment(double[] coords)
+ {
+ if (i == -1)
+ {
+ coords[0] = x[right];
+ coords[1] = y[right];
+ return SEG_MOVETO;
+ }
+
+ coords[0] = x[i];
+ coords[1] = y[i];
+ return SEG_LINETO;
+ }
+ }
+
+ private class TransformIterator extends SimpleIterator
+ {
+ private final AffineTransform transform;
+
+ TransformIterator(AffineTransform transform)
+ {
+ this.transform = transform;
+ }
+
+ @Override
+ public int currentSegment(float[] coords)
+ {
+ int v = super.currentSegment(coords);
+ transform.transform(coords, 0, coords, 0, 2);
+ return v;
+ }
+
+ @Override
+ public int currentSegment(double[] coords)
+ {
+ int v = super.currentSegment(coords);
+ transform.transform(coords, 0, coords, 0, 2);
+ return v;
+ }
+ }
+}
diff --git a/runelite-api/src/main/java/net/runelite/api/model/Jarvis.java b/runelite-api/src/main/java/net/runelite/api/model/Jarvis.java
index ba29c86b6d..0c60b84462 100644
--- a/runelite-api/src/main/java/net/runelite/api/model/Jarvis.java
+++ b/runelite-api/src/main/java/net/runelite/api/model/Jarvis.java
@@ -24,9 +24,9 @@
*/
package net.runelite.api.model;
-import java.util.ArrayList;
import java.util.List;
import net.runelite.api.Point;
+import net.runelite.api.geometry.SimplePolygon;
/**
* Provides utility methods for computing the convex hull of a list of
@@ -41,92 +41,147 @@ public class Jarvis
/**
* Computes and returns the convex hull of the passed points.
*
- * The size of the list must be at least 4, otherwise this method will
+ * The size of the list must be at least 3, otherwise this method will
* return null.
*
* @param points list of points
* @return list containing the points part of the convex hull
*/
+ @Deprecated
public static List convexHull(List points)
{
- if (points.size() < 3)
+ int[] xs = new int[points.size()];
+ int[] ys = new int[xs.length];
+ for (int i = 0; i < xs.length; i++)
+ {
+ Point p = points.get(i);
+ xs[i] = p.getX();
+ ys[i] = p.getY();
+ }
+
+ SimplePolygon poly = convexHull(xs, ys);
+ if (poly == null)
{
return null;
}
- List ch = new ArrayList<>();
+ return poly.toRuneLitePointList();
+ }
+
+ /**
+ * Computes and returns the convex hull of the passed points.
+ *
+ * The size of the list must be at least 3, otherwise this method will
+ * return null.
+ *
+ * @return a shape the points part of the convex hull
+ */
+ public static SimplePolygon convexHull(int[] xs, int[] ys)
+ {
+ int length = xs.length;
+
+ // remove any invalid entries
+ {
+ int i = 0, offset = 0;
+ for (; i < length; i++)
+ {
+ if (xs[i] == Integer.MIN_VALUE)
+ {
+ offset++;
+ i++;
+ break;
+ }
+ }
+ for (; i < length; i++)
+ {
+ if (xs[i] == Integer.MIN_VALUE)
+ {
+ offset++;
+ continue;
+ }
+ xs[i - offset] = xs[i];
+ ys[i - offset] = ys[i];
+ }
+ length -= offset;
+ }
+
+ if (length < 3)
+ {
+ return null;
+ }
// find the left most point
- Point left = findLeftMost(points);
+ int left = findLeftMost(xs, ys, length);
// current point we are on
- Point current = left;
+ int current = left;
+
+ SimplePolygon out = new SimplePolygon(new int[16], new int[16], 0);
do
{
- ch.add(current);
- assert ch.size() <= points.size() : "hull has more points than graph";
- if (ch.size() > points.size())
+ int cx = xs[current];
+ int cy = ys[current];
+ out.pushRight(cx, cy);
+
+ if (out.size() > length)
{
- // Just to make sure we never somehow get stuck in this loop
return null;
}
// the next point - all points are to the right of the
// line between current and next
- Point next = null;
+ int next = 0;
+ int nx = xs[next];
+ int ny = ys[next];
- for (Point p : points)
+ for (int i = 1; i < length; i++)
{
- if (next == null)
+ long cp = crossProduct(cx, cy, xs[i], ys[i], nx, ny);
+ if (cp > 0 || (cp == 0 && square(cx - xs[i]) + square(cy - ys[i]) > square(cx - nx) + square(cy - ny)))
{
- next = p;
- continue;
+ next = i;
+ nx = xs[next];
+ ny = ys[next];
}
-
- long cp = crossProduct(current, p, next);
- if (cp > 0 || (cp == 0 && current.distanceTo(p) > current.distanceTo(next)))
- {
- next = p;
- }
- }
-
- // Points can be null if they are behind or very close to the camera.
- if (next == null)
- {
- return null;
}
current = next;
}
while (current != left);
- return ch;
+ return out;
}
- private static Point findLeftMost(List points)
+ private static int square(int x)
{
- Point left = null;
+ return x * x;
+ }
- for (Point p : points)
+ private static int findLeftMost(int[] xs, int[] ys, int length)
+ {
+ int idx = 0;
+ int x = xs[idx];
+ int y = ys[idx];
+
+ for (int i = 1; i < length; i++)
{
- if (left == null || p.getX() < left.getX())
+ int ix = xs[i];
+ if (ix < x || ix == x && ys[i] < y)
{
- left = p;
- }
- else if (p.getX() == left.getX() && p.getY() < left.getY())
- {
- left = p;
+ idx = i;
+ x = xs[idx];
+ y = ys[idx];
}
}
- return left;
+ return idx;
}
- private static long crossProduct(Point p, Point q, Point r)
+ private static long crossProduct(int px, int py, int qx, int qy, int rx, int ry)
{
- long val = (long)(q.getY() - p.getY()) * (r.getX() - q.getX())
- - (long)(q.getX() - p.getX()) * (r.getY() - q.getY());
+ long val = (long) (qy - py) * (rx - qx)
+ - (long) (qx - px) * (ry - qy);
return val;
}
}
diff --git a/runelite-api/src/main/java/net/runelite/api/model/Triangle.java b/runelite-api/src/main/java/net/runelite/api/model/Triangle.java
deleted file mode 100644
index daf59c2489..0000000000
--- a/runelite-api/src/main/java/net/runelite/api/model/Triangle.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2017, Adam
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package net.runelite.api.model;
-
-import lombok.Value;
-
-/**
- * Represents 3 vertices as a three-dimensional Triangle.
- */
-@Value
-public class Triangle
-{
- private final Vertex a;
- private final Vertex b;
- private final Vertex c;
-
- /**
- * Rotates the triangle by the given orientation.
- *
- * @param orientation passed orientation
- * @return new instance
- */
- public Triangle rotate(int orientation)
- {
- return new Triangle(
- a.rotate(orientation),
- b.rotate(orientation),
- c.rotate(orientation)
- );
- }
-
-}
diff --git a/runelite-api/src/main/java/net/runelite/api/model/Vertex.java b/runelite-api/src/main/java/net/runelite/api/model/Vertex.java
deleted file mode 100644
index b59a7d7891..0000000000
--- a/runelite-api/src/main/java/net/runelite/api/model/Vertex.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2017, Adam
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package net.runelite.api.model;
-
-import lombok.Value;
-import net.runelite.api.Perspective;
-
-/**
- * Represents a point in a three-dimensional space.
- */
-@Value
-public class Vertex
-{
- private final int x;
- private final int y;
- private final int z;
-
- /**
- * Rotates the triangle by the given orientation.
- *
- * @param orientation passed orientation
- * @return new instance
- */
- public Vertex rotate(int orientation)
- {
- // models are orientated north (1024) and there are 2048 angles total
- orientation = (orientation + 1024) % 2048;
-
- if (orientation == 0)
- {
- return this;
- }
-
- int sin = Perspective.SINE[orientation];
- int cos = Perspective.COSINE[orientation];
-
- return new Vertex(
- x * cos + z * sin >> 16,
- y,
- z * cos - x * sin >> 16
- );
- }
-}
diff --git a/runelite-api/src/test/java/net/runelite/api/geometry/RectangleUnionTest.java b/runelite-api/src/test/java/net/runelite/api/geometry/RectangleUnionTest.java
new file mode 100644
index 0000000000..f8d714180b
--- /dev/null
+++ b/runelite-api/src/test/java/net/runelite/api/geometry/RectangleUnionTest.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2019 Abex
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package net.runelite.api.geometry;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import javax.imageio.ImageIO;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.Assert;
+
+@Slf4j
+public class RectangleUnionTest
+{
+ private static final int ITERATIONS = 100;
+ private static final int WIDTH = 1000;
+ private static final int MAX_RECTS = 50;
+
+ // @Test
+ public void test() throws IOException
+ {
+ for (int count = 1; count < MAX_RECTS; count++)
+ {
+ for (int r = 0; r < ITERATIONS; r++)
+ {
+ Random rand = new Random(count << 16 | r);
+ String id = count + "rects_iteration" + r;
+ log.info(id);
+ BufferedImage wanted = new BufferedImage(WIDTH, WIDTH, BufferedImage.TYPE_BYTE_BINARY);
+ BufferedImage got = new BufferedImage(WIDTH, WIDTH, BufferedImage.TYPE_BYTE_BINARY);
+
+ Graphics2D wg = wanted.createGraphics();
+ wg.setColor(Color.WHITE);
+ Graphics2D gg = got.createGraphics();
+ gg.setColor(Color.WHITE);
+
+ List rects = new ArrayList<>(count);
+
+ for (int i = 0; i < count; i++)
+ {
+ int x1, y1, x2, y2;
+
+ do
+ {
+ x1 = rand.nextInt(WIDTH);
+ x2 = rand.nextInt(WIDTH);
+ }
+ while (x1 >= x2);
+
+ do
+ {
+ y1 = rand.nextInt(WIDTH);
+ y2 = rand.nextInt(WIDTH);
+ }
+ while (y1 >= y2);
+
+ RectangleUnion.Rectangle rect = new RectangleUnion.Rectangle(x1, y1, x2, y2);
+ log.trace("{}", rect);
+ rects.add(rect);
+
+ wg.fillRect(x1, y1, x2 - x1, y2 - y1);
+ }
+
+ Shape union = RectangleUnion.union(rects);
+
+ gg.fill(union);
+
+ loop:
+ for (int x = 0; x < WIDTH; x++)
+ {
+ for (int y = 0; y < WIDTH; y++)
+ {
+ if (wanted.getRGB(x, y) != got.getRGB(x, y))
+ {
+ File tmp = new File(System.getProperty("java.io.tmpdir"));
+ ImageIO.write(wanted, "png", new File(tmp, id + "_wanted.png"));
+ ImageIO.write(got, "png", new File(tmp, id + "_got.png"));
+
+ Assert.fail(id);
+ break loop;
+ }
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityOverlay.java
index e9c205f64f..c012b945dc 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityOverlay.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityOverlay.java
@@ -29,7 +29,7 @@ import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Polygon;
-import java.awt.geom.Area;
+import java.awt.Shape;
import java.util.List;
import javax.inject.Inject;
import net.runelite.api.Client;
@@ -90,7 +90,7 @@ class AgilityOverlay extends Overlay
}
return;
}
- Area objectClickbox = object.getClickbox();
+ Shape objectClickbox = object.getClickbox();
if (objectClickbox != null)
{
AgilityShortcut agilityShortcut = obstacle.getShortcut();
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnaceClickBoxOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnaceClickBoxOverlay.java
index 9dba17df30..ea09b36e63 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnaceClickBoxOverlay.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnaceClickBoxOverlay.java
@@ -27,7 +27,7 @@ package net.runelite.client.plugins.blastfurnace;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
-import java.awt.geom.Area;
+import java.awt.Shape;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.api.EquipmentInventorySlot;
@@ -110,7 +110,7 @@ class BlastFurnaceClickBoxOverlay extends Overlay
if (localLocation.distanceTo(location) <= MAX_DISTANCE)
{
- Area objectClickbox = object.getClickbox();
+ Shape objectClickbox = object.getClickbox();
if (objectClickbox != null)
{
if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY()))
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsOverlay.java
index 457a86b766..aa2f55bd27 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsOverlay.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsOverlay.java
@@ -32,6 +32,7 @@ import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.awt.Rectangle;
+import java.awt.Shape;
import java.awt.geom.Rectangle2D;
import java.util.List;
import javax.inject.Inject;
@@ -286,10 +287,10 @@ class DevToolsOverlay extends Overlay
// Draw a polygon around the convex hull
// of the model vertices
- Polygon p = gameObject.getConvexHull();
+ Shape p = gameObject.getConvexHull();
if (p != null)
{
- graphics.drawPolygon(p);
+ graphics.draw(p);
}
}
}
@@ -330,16 +331,16 @@ class DevToolsOverlay extends Overlay
OverlayUtil.renderTileOverlay(graphics, decorObject, "ID: " + decorObject.getId(), DEEP_PURPLE);
}
- Polygon p = decorObject.getConvexHull();
+ Shape p = decorObject.getConvexHull();
if (p != null)
{
- graphics.drawPolygon(p);
+ graphics.draw(p);
}
p = decorObject.getConvexHull2();
if (p != null)
{
- graphics.drawPolygon(p);
+ graphics.draw(p);
}
}
}
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/herbiboars/HerbiboarOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/herbiboars/HerbiboarOverlay.java
index 653228cdb3..a97f5d9d49 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/herbiboars/HerbiboarOverlay.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/herbiboars/HerbiboarOverlay.java
@@ -28,7 +28,7 @@ import com.google.inject.Inject;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
-import java.awt.geom.Area;
+import java.awt.Shape;
import java.util.Set;
import net.runelite.api.TileObject;
import net.runelite.api.coords.WorldPoint;
@@ -103,7 +103,7 @@ class HerbiboarOverlay extends Overlay
{
if (config.showClickBoxes())
{
- Area clickbox = object.getClickbox();
+ Shape clickbox = object.getClickbox();
if (clickbox != null)
{
graphics.setColor(config.getObjectColor());
@@ -129,7 +129,7 @@ class HerbiboarOverlay extends Overlay
{
if (config.showClickBoxes())
{
- Area clickbox = object.getClickbox();
+ Shape clickbox = object.getClickbox();
if (clickbox != null)
{
Color col = config.getObjectColor();
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcSceneOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcSceneOverlay.java
index ae252aef93..fef1b03c8a 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcSceneOverlay.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcSceneOverlay.java
@@ -30,6 +30,7 @@ import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Polygon;
+import java.awt.Shape;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.time.Instant;
@@ -167,7 +168,7 @@ public class NpcSceneOverlay extends Overlay
break;
case HULL:
- Polygon objectClickbox = actor.getConvexHull();
+ Shape objectClickbox = actor.getConvexHull();
renderPoly(graphics, color, objectClickbox);
break;
@@ -185,7 +186,7 @@ public class NpcSceneOverlay extends Overlay
}
}
- private void renderPoly(Graphics2D graphics, Color color, Polygon polygon)
+ private void renderPoly(Graphics2D graphics, Color color, Shape polygon)
{
if (polygon != null)
{
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsOverlay.java
index 509b3f5bde..a61aa526dc 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsOverlay.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsOverlay.java
@@ -26,7 +26,7 @@ package net.runelite.client.plugins.objectindicators;
import java.awt.Dimension;
import java.awt.Graphics2D;
-import java.awt.Polygon;
+import java.awt.Shape;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.api.DecorativeObject;
@@ -66,8 +66,8 @@ class ObjectIndicatorsOverlay extends Overlay
continue;
}
- final Polygon polygon;
- Polygon polygon2 = null;
+ final Shape polygon;
+ Shape polygon2 = null;
if (object instanceof GameObject)
{
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/roguesden/RoguesDenOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/roguesden/RoguesDenOverlay.java
index 4b5cc234e1..1dc0aa0bc6 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/roguesden/RoguesDenOverlay.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/roguesden/RoguesDenOverlay.java
@@ -28,6 +28,7 @@ import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Polygon;
+import java.awt.Shape;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.api.coords.LocalPoint;
@@ -65,11 +66,11 @@ public class RoguesDenOverlay extends Overlay
{
if (tile.getPlane() == client.getPlane() && obstacle.getLocalLocation().distanceTo(playerLocation) < MAX_DISTANCE)
{
- Polygon p = tile.getGameObjects()[0].getConvexHull();
+ Shape p = tile.getGameObjects()[0].getConvexHull();
if (p != null)
{
graphics.setColor(Color.CYAN);
- graphics.drawPolygon(p);
+ graphics.draw(p);
}
}
});
@@ -82,7 +83,7 @@ public class RoguesDenOverlay extends Overlay
if (p != null)
{
graphics.setColor(Color.CYAN);
- graphics.drawPolygon(p);
+ graphics.draw(p);
}
}
});
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/AbyssOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/AbyssOverlay.java
index b4d3df3e18..0981628dc9 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/AbyssOverlay.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/AbyssOverlay.java
@@ -26,7 +26,7 @@ package net.runelite.client.plugins.runecraft;
import java.awt.Color;
import java.awt.Polygon;
-import java.awt.geom.Area;
+import java.awt.Shape;
import com.google.inject.Inject;
import java.awt.Dimension;
import java.awt.Graphics2D;
@@ -105,7 +105,7 @@ class AbyssOverlay extends Overlay
}
Point mousePosition = client.getMouseCanvasPosition();
- Area objectClickbox = object.getClickbox();
+ Shape objectClickbox = object.getClickbox();
if (objectClickbox != null)
{
if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY()))
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TargetClickboxOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TargetClickboxOverlay.java
index cc52cf9ac1..52b5b31865 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TargetClickboxOverlay.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TargetClickboxOverlay.java
@@ -30,7 +30,7 @@ import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
-import java.awt.Polygon;
+import java.awt.Shape;
import java.util.List;
import javax.inject.Inject;
import net.runelite.api.NPC;
@@ -71,7 +71,7 @@ public class TargetClickboxOverlay extends Overlay
private void renderTargetOverlay(Graphics2D graphics, NPC actor, Color color)
{
- Polygon objectClickbox = actor.getConvexHull();
+ Shape objectClickbox = actor.getConvexHull();
if (objectClickbox != null)
{
graphics.setColor(color);
diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayUtil.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayUtil.java
index f15bc0124e..912abab8f4 100644
--- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayUtil.java
+++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayUtil.java
@@ -31,8 +31,8 @@ import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.awt.RenderingHints;
+import java.awt.Shape;
import java.awt.Stroke;
-import java.awt.geom.Area;
import java.awt.image.BufferedImage;
import net.runelite.api.Actor;
import net.runelite.api.Client;
@@ -50,14 +50,14 @@ public class OverlayUtil
private static final int MINIMAP_DOT_RADIUS = 4;
private static final double UNIT = Math.PI / 1024.0d;
- public static void renderPolygon(Graphics2D graphics, Polygon poly, Color color)
+ public static void renderPolygon(Graphics2D graphics, Shape poly, Color color)
{
graphics.setColor(color);
final Stroke originalStroke = graphics.getStroke();
graphics.setStroke(new BasicStroke(2));
- graphics.drawPolygon(poly);
+ graphics.draw(poly);
graphics.setColor(new Color(0, 0, 0, 50));
- graphics.fillPolygon(poly);
+ graphics.fill(poly);
graphics.setStroke(originalStroke);
}
@@ -175,7 +175,7 @@ public class OverlayUtil
renderImageLocation(client, graphics, localLocation, image, 0);
}
- public static void renderHoverableArea(Graphics2D graphics, Area area, net.runelite.api.Point mousePosition, Color fillColor, Color borderColor, Color borderHoverColor)
+ public static void renderHoverableArea(Graphics2D graphics, Shape area, net.runelite.api.Point mousePosition, Color fillColor, Color borderColor, Color borderHoverColor)
{
if (area != null)
{