commit 6fdddd6454621f392bb438bba6356a94b39c100f Author: MrLetsplay Date: Fri Sep 29 22:08:03 2023 +0200 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f2c6116 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.settings +bin +.classpath diff --git a/.project b/.project new file mode 100644 index 0000000..d7e54d3 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + GarticPhoneCheats + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/amogus.jpg b/amogus.jpg new file mode 100644 index 0000000..27b5733 Binary files /dev/null and b/amogus.jpg differ diff --git a/cock.jpg b/cock.jpg new file mode 100644 index 0000000..459e3e8 Binary files /dev/null and b/cock.jpg differ diff --git a/src/GarticPhoneCheats.java b/src/GarticPhoneCheats.java new file mode 100644 index 0000000..96272bf --- /dev/null +++ b/src/GarticPhoneCheats.java @@ -0,0 +1,122 @@ +import java.awt.Color; +import java.awt.MouseInfo; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.image.BufferedImage; +import java.io.File; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +import javax.imageio.ImageIO; + +public class GarticPhoneCheats { + + public static void main(String[] args) throws Exception { + BufferedImage img = ImageIO.read(new File("cock.jpg")); + Robot r = new Robot(); + + System.out.println("Top left"); + Thread.sleep(3000); + Point topLeft = MouseInfo.getPointerInfo().getLocation(); + + System.out.println("Bottom right"); + Thread.sleep(3000); + Point bottomRight = MouseInfo.getPointerInfo().getLocation(); + + System.out.println("TL colors"); + Thread.sleep(3000); + Point topLeftC = MouseInfo.getPointerInfo().getLocation(); + + System.out.println("BR colors"); + Thread.sleep(3000); + Point bottomRightC = MouseInfo.getPointerInfo().getLocation(); + + int poop = 5; + Map colors = new HashMap<>(); + Rectangle colRect = new Rectangle(topLeftC.x, topLeftC.y, bottomRightC.x - topLeftC.x, bottomRightC.y - topLeftC.y); + BufferedImage colorImage = r.createScreenCapture(colRect); + for(int x = 0; x < colorImage.getWidth(); x++) { + yLoop: for(int y = 0; y < colorImage.getHeight(); y++) { + int rgb = colorImage.getRGB(x, y); + for(int dx = -poop; dx <= poop; dx++) { + for(int dy = -poop; dy <= poop; dy++) { + if(x + dx < 0 || x + dx >= colorImage.getWidth() || y + dy < 0 || y + dy >= colorImage.getHeight()) continue yLoop; + if(colorImage.getRGB(x + dx, y + dy) != rgb) continue yLoop; + } + } + colors.put(new Color(rgb), new Point(topLeftC.x + x, topLeftC.y + y)); + } + } + + System.out.println(colors); + + Rectangle drawRect = new Rectangle(topLeft.x, topLeft.y, bottomRight.x - topLeft.x, bottomRight.y - topLeft.y); + double ratio = img.getWidth() / (double) img.getHeight(); + double targetRatio = drawRect.width / (double) drawRect.height; + + int nW, nH; + if(ratio > targetRatio) { + nW = drawRect.width; + nH = (int) (drawRect.width / ratio); + }else { + nH = drawRect.height; + nW = (int) (drawRect.height * ratio); + } + + System.out.println(nW + "," + nH); + System.out.println(drawRect); + + BufferedImage nImg = new BufferedImage(nW, nH, BufferedImage.TYPE_3BYTE_BGR); + nImg.createGraphics().drawImage(img, 0, 0, nW, nH, null); + + int scale = 10; + int delay = 7; + + Color selectedColor = null; + for(int x = 0; x < nImg.getWidth() / scale; x++) { + for(int y = 0; y < nImg.getHeight() / scale; y++) { + int rgb = nImg.getRGB(x * scale, y * scale); + + int pX = topLeft.x + x * scale; + int pY = topLeft.y + y * scale; + if(pX < topLeft.x || pX > bottomRight.x || pY < topLeft.y || pY > bottomRight.y) continue; + + Color col = new Color(rgb); + Color closest = colors.keySet().stream() + .sorted(Comparator.comparingDouble(c -> dist(c, col))) + .findFirst().orElse(null); + + if(!Objects.equals(selectedColor, closest)) { + Thread.sleep(2 * delay); + + selectedColor = closest; + Point colPoint = colors.get(closest); + r.mouseMove(colPoint.x, colPoint.y); + + r.mousePress(InputEvent.BUTTON1_DOWN_MASK); + Thread.sleep(delay); + r.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + } + + r.mouseMove(pX, pY); + r.mousePress(InputEvent.BUTTON1_DOWN_MASK); + Thread.sleep(delay); + r.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + Thread.sleep(delay); + } + } + } + + private static int dist(Color a, Color b) { + int dR = Math.abs(a.getRed() - b.getRed()); + int dG = Math.abs(a.getGreen() - b.getGreen()); + int dB = Math.abs(a.getBlue() - b.getBlue()); + return dR * dR + dG * dG + dB * dB; + } + +} diff --git a/testimg.jpg b/testimg.jpg new file mode 100644 index 0000000..e719612 Binary files /dev/null and b/testimg.jpg differ