Package net.runelite.api.geometry
Class Geometry
- java.lang.Object
-
- net.runelite.api.geometry.Geometry
-
public class Geometry extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Geometry()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.awt.geom.GeneralPathclipPath(java.awt.geom.GeneralPath path, java.awt.Shape shape)Removes lines from a path that lie outside the clipping area and cuts lines intersecting with the clipping area so the resulting lines lie within the clipping area.static java.awt.geom.GeneralPathclipPath(java.awt.geom.PathIterator it, java.awt.Shape shape)Removes lines from a path that lie outside the clipping area and cuts lines intersecting with the clipping area so the resulting lines lie within the clipping area.static java.awt.geom.GeneralPathfilterPath(java.awt.geom.GeneralPath path, java.util.function.BiPredicate<float[],float[]> method)Removes lines from a path according to a method.static java.awt.geom.GeneralPathfilterPath(java.awt.geom.PathIterator it, java.util.function.BiPredicate<float[],float[]> method)Removes lines from a path according to a method.static java.util.List<java.awt.geom.Point2D.Float>intersectionPoints(java.awt.Shape shape, float x1, float y1, float x2, float y2)Find the intersection points between a Shape and a line.static java.awt.geom.Point2D.FloatlineIntersectionPoint(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)Find the point where two lines intersect.static java.awt.geom.GeneralPathsplitIntoSegments(java.awt.geom.GeneralPath path, float segmentLength)Splits a path into smaller segments.static java.awt.geom.GeneralPathsplitIntoSegments(java.awt.geom.PathIterator it, float segmentLength)Splits a path into smaller segments.static java.awt.geom.GeneralPathtransformPath(java.awt.geom.GeneralPath path, java.util.function.Consumer<float[]> method)Transforms the points in a path according to a method.static java.awt.geom.GeneralPathtransformPath(java.awt.geom.PathIterator it, java.util.function.Consumer<float[]> method)Transforms the points in a path according to a method.
-
-
-
Method Detail
-
lineIntersectionPoint
public static java.awt.geom.Point2D.Float lineIntersectionPoint(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)Find the point where two lines intersect.- Parameters:
x1- X coordinate of the first endpoint of the first line.y1- Y coordinate of the first endpoint of the first line.x2- X coordinate of the second endpoint of the first line.y2- Y coordinate of the second endpoint of the first line.x3- X coordinate of the first endpoint of the second line.y3- Y coordinate of the first endpoint of the second line.x4- X coordinate of the second endpoint of the second line.y4- Y coordinate of the second endpoint of the second line.- Returns:
- The intersection point of the lines, or null if the lines don't intersect.
-
intersectionPoints
public static java.util.List<java.awt.geom.Point2D.Float> intersectionPoints(java.awt.Shape shape, float x1, float y1, float x2, float y2)Find the intersection points between a Shape and a line.- Parameters:
shape- The shape.x1- X coordinate of the first endpoint of the line.y1- Y coordinate of the first endpoint of the line.x2- X coordinate of the second endpoint of the line.y2- Y coordinate of the second endpoint of the line.- Returns:
- A list with the intersection points.
-
transformPath
public static java.awt.geom.GeneralPath transformPath(java.awt.geom.PathIterator it, java.util.function.Consumer<float[]> method)Transforms the points in a path according to a method.- Parameters:
it- The iterator of the path to change the points on.method- The method to use to transform the points. Takes a float[2] array with x and y coordinates as parameter.- Returns:
- The transformed path.
-
transformPath
public static java.awt.geom.GeneralPath transformPath(java.awt.geom.GeneralPath path, java.util.function.Consumer<float[]> method)Transforms the points in a path according to a method.- Parameters:
path- The path to change the points on.method- The method to use to transform the points. Takes a float[2] array with x and y coordinates as parameter.- Returns:
- The transformed path.
-
splitIntoSegments
public static java.awt.geom.GeneralPath splitIntoSegments(java.awt.geom.PathIterator it, float segmentLength)Splits a path into smaller segments. For example, calling this on a path with a line of length 6, with desired segment length of 2, would split the path into 3 consecutive lines of length 2.- Parameters:
it- The iterator of the path to modify.segmentLength- The desired length to use for the segments.- Returns:
- The modified path.
-
splitIntoSegments
public static java.awt.geom.GeneralPath splitIntoSegments(java.awt.geom.GeneralPath path, float segmentLength)Splits a path into smaller segments. For example, calling this on a path with a line of length 6, with desired segment length of 2, would split the path into 3 consecutive lines of length 2.- Parameters:
path- The path to modify.segmentLength- The desired length to use for the segments.- Returns:
- The modified path.
-
filterPath
public static java.awt.geom.GeneralPath filterPath(java.awt.geom.PathIterator it, java.util.function.BiPredicate<float[],float[]> method)Removes lines from a path according to a method.- Parameters:
it- The iterator of the path to filter.method- The method to use to decide which lines to remove. Takes two float[2] arrays with x and y coordinates of the endpoints of the line. Lines for which the predicate returns false are removed.- Returns:
- The filtered path.
-
filterPath
public static java.awt.geom.GeneralPath filterPath(java.awt.geom.GeneralPath path, java.util.function.BiPredicate<float[],float[]> method)Removes lines from a path according to a method.- Parameters:
path- The path to filter.method- The method to use to decide which lines to remove. Takes two float[2] arrays with x and y coordinates of the endpoints of the line. Lines for which the predicate returns false are removed.- Returns:
- The filtered path.
-
clipPath
public static java.awt.geom.GeneralPath clipPath(java.awt.geom.PathIterator it, java.awt.Shape shape)Removes lines from a path that lie outside the clipping area and cuts lines intersecting with the clipping area so the resulting lines lie within the clipping area.- Parameters:
it- The iterator of the path to clip.shape- The clipping area to clip with.- Returns:
- The clipped path.
-
clipPath
public static java.awt.geom.GeneralPath clipPath(java.awt.geom.GeneralPath path, java.awt.Shape shape)Removes lines from a path that lie outside the clipping area and cuts lines intersecting with the clipping area so the resulting lines lie within the clipping area.- Parameters:
path- The path to clip.shape- The clipping area to clip with.- Returns:
- The clipped path.
-
-