initial commit

This commit is contained in:
MrLetsplay 2023-09-29 22:08:03 +02:00
commit 6fdddd6454
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg
6 changed files with 142 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.settings
bin
.classpath

17
.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>GarticPhoneCheats</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

BIN
amogus.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
cock.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

122
src/GarticPhoneCheats.java Normal file
View File

@ -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<Color, Point> 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;
}
}

BIN
testimg.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB