-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package yaku.math; | ||
|
||
import java.awt.*; | ||
import java.util.ArrayList; | ||
|
||
public class PathfindingUtils { | ||
|
||
public static Point getNextBestPoint(Point startPos, ArrayList<Point> points) { | ||
Point furthestPoint = null; | ||
double maxDistance = -1; | ||
|
||
for (Point point : points) { | ||
if (isRaytraceable(startPos, point, points) && point.getX() > maxDistance) { | ||
maxDistance = point.getX(); | ||
furthestPoint = point; | ||
} | ||
} | ||
|
||
return furthestPoint; | ||
} | ||
|
||
private static boolean isRaytraceable(Point start, Point end, ArrayList<Point> points) { | ||
for (Point point : points) { | ||
if (point != start && point != end && !points.contains(point)) { | ||
if (isPointBetween(start, end, point)) { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
private static boolean isPointBetween(Point start, Point end, Point point) { | ||
double minX = Math.min(start.getX(), end.getX()); | ||
double minY = Math.min(start.getY(), end.getY()); | ||
double maxX = Math.max(start.getX(), end.getX()); | ||
double maxY = Math.max(start.getY(), end.getY()); | ||
|
||
return point.getX() >= minX && point.getX() <= maxX && point.getY() >= minY && point.getY() <= maxY; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package yaku.other; | ||
|
||
import java.awt.Color; | ||
|
||
|
||
/** | ||
* @author EBSmash | ||
*<p> | ||
* Utility class for working with colors in Java. | ||
* Provides methods to modify individual color components (red, green, blue, alpha). | ||
*/ | ||
public class ColorUtils { | ||
public static Color modifyRed(Color color, int newRed) { | ||
int green = color.getGreen(); | ||
int blue = color.getBlue(); | ||
int alpha = color.getAlpha(); | ||
|
||
return new Color(newRed, green, blue, alpha); | ||
} | ||
|
||
public static Color modifyGreen(Color color, int newGreen) { | ||
int red = color.getRed(); | ||
int blue = color.getBlue(); | ||
int alpha = color.getAlpha(); | ||
|
||
return new Color(red, newGreen, blue, alpha); | ||
} | ||
|
||
public static Color modifyBlue(Color color, int newBlue) { | ||
int red = color.getRed(); | ||
int green = color.getGreen(); | ||
int alpha = color.getAlpha(); | ||
|
||
return new Color(red, green, newBlue, alpha); | ||
} | ||
|
||
public static Color modifyAlpha(Color color, int newAlpha) { | ||
int red = color.getRed(); | ||
int green = color.getGreen(); | ||
int blue = color.getBlue(); | ||
|
||
return new Color(red, green, blue, newAlpha); | ||
} | ||
|
||
} |