-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAimbot.java
More file actions
107 lines (84 loc) · 3.46 KB
/
Aimbot.java
File metadata and controls
107 lines (84 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.WritableRaster;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
class Aimbot {
private List<ColorConfig> colorConfigs = Arrays.asList(
new ColorConfig(18, 360, 0, 80, 100, 1),
new ColorConfig(220, 360, 0, 83, 100, 1)
);
private BufferedImage takeScreenshot() throws AWTException {
return new Robot().createScreenCapture(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds());
}
private Aimbot() throws IOException, AWTException {
BufferedImage img = takeScreenshot();
ImageIO.write(img, "png", new File("gen/screenshot.png"));
List<BufferedImage> colorLayers = new ArrayList<>();
for (int idColorConfig = 0; idColorConfig < colorConfigs.size(); idColorConfig++) {
ColorModel cm = img.getColorModel();
WritableRaster raster = img.copyData(null);
BufferedImage copy = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_ARGB);
colorLayers.add(copy);
ColorConfig currentColorConfig = colorConfigs.get(idColorConfig);
int width = img.getWidth();
int height = img.getHeight();
double CEIL = 0.1;
for (int i=0; i<height; i++) {
for (int j=0; j<width; j++) {
Color current = new Color(img.getRGB(j,i));
float[] hsb = Color.RGBtoHSB(current.getRed(),current.getGreen(), current.getBlue(), null);
List<Double> allPcts = Arrays.asList(
getDiffPct(currentColorConfig.targetSaturation, currentColorConfig.targetSaturationMax, hsb[currentColorConfig.saturationIndex]),
getDiffPct(currentColorConfig.targetHue, currentColorConfig.targetHueMax, hsb[currentColorConfig.hueIndex])
);
double avDiffPct = calculateAverage(allPcts);
int diff255 = (int)Math.round((avDiffPct > CEIL ? 1 : 0) * 255);
int alpha = (int)Math.round((avDiffPct > CEIL ? 0 : 1) * 255);
Color resColor = new Color(diff255, diff255, diff255, alpha);
colorLayers.get(idColorConfig).setRGB(j,i,resColor.getRGB());
}
}
ImageIO.write(colorLayers.get(idColorConfig), "png", new File("gen/output"+idColorConfig+".png"));
}
BufferedImage colorLayer = colorLayers.get(0);
ColorPanel cp = new ColorPanel();
cp.setImage(colorLayer);
JFrame frame = new JFrame("Glass aim");
frame.setLocationByPlatform(false);
frame.setUndecorated(true);
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setBackground(new Color(0, 0, 0, 0));
frame.add(cp);
frame.setAlwaysOnTop(true);
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) throws IOException, AWTException {
new Aimbot();
}
private static double getDiffPct(int target, double targetMax, float comp) {
return Collections.min(Arrays.asList(
Math.abs((comp * targetMax - targetMax)-target),
Math.abs((comp * targetMax)-target),
Math.abs((comp * targetMax + targetMax)-target)
))/ targetMax;
}
private double calculateAverage(List<Double> values) {
double sum = 0;
if(!values.isEmpty()) {
for (double v : values) {
sum += v;
}
return sum / values.size();
}
return sum;
}
}