Skip to content

Commit

Permalink
v0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ElijahBare committed Jun 22, 2023
1 parent 37762d3 commit f00aac8
Show file tree
Hide file tree
Showing 9 changed files with 269 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions yakulib/src/main/java/yaku/math/PathfindingUtils.java
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;
}
}
45 changes: 45 additions & 0 deletions yakulib/src/main/java/yaku/other/ColorUtils.java
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);
}

}

0 comments on commit f00aac8

Please sign in to comment.