-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
112 lines (100 loc) · 3.03 KB
/
index.js
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
108
109
110
111
112
const robot = require("robotjs");
const hueek = {}
hueek.width = robot.getScreenSize().width;
hueek.height = robot.getScreenSize().height;
console.log(hueek.width*0.10);
const cordinates1 = {
x1: 10,
y1: 10,
x2: hueek.width*0.10,
y2: 10,
x3: 10,
y3: hueek.height*0.50,
x4: hueek.width*0.10,
y4: hueek.height*0.50,
x5: 10,
y5: hueek.height*0.90,
x6: hueek.width*0.10,
y6: hueek.height*0.90,
}
const cordinates2 = {
x1: hueek.width*0.10,
y1: 10,
x2: hueek.width*0.50,
y2: 10,
x3: hueek.width*0.50,
y3: hueek.height*0.50,
x4: hueek.width*0.10,
y4: hueek.height*0.50,
x5: hueek.width*0.10,
y5: hueek.height*0.90,
x6: hueek.width*0.50,
y6: hueek.height*0.90,
}
const cordinates3 = {
x1: hueek.width*0.90,
y1: 10,
x2: hueek.width-10,
y2: 10,
x3: hueek.width-10,
y3: hueek.height*0.50,
x4: hueek.width*0.90,
y4: hueek.height*0.50,
x5: hueek.width*0.90,
y5: hueek.height*0.90,
x6: hueek.width-10,
y6: hueek.height*0.90,
}
const colors1 = {
color1: robot.getPixelColor(cordinates1.x1,cordinates1.y1),
color2: robot.getPixelColor(cordinates1.x2,cordinates1.y2),
color3: robot.getPixelColor(cordinates1.x3,cordinates1.y3),
color4: robot.getPixelColor(cordinates1.x4,cordinates1.y4),
color5: robot.getPixelColor(cordinates1.x5,cordinates1.y5),
color6: robot.getPixelColor(cordinates1.x6,cordinates1.y6)
}
const colors2 = {
color1: robot.getPixelColor(cordinates2.x1,cordinates2.y1),
color2: robot.getPixelColor(cordinates2.x2,cordinates2.y2),
color3: robot.getPixelColor(cordinates2.x3,cordinates2.y3),
color4: robot.getPixelColor(cordinates2.x4,cordinates2.y4),
color5: robot.getPixelColor(cordinates2.x5,cordinates2.y5),
color6: robot.getPixelColor(cordinates2.x6,cordinates2.y6)
}
const color3 = {
color1: robot.getPixelColor(cordinates3.x1,cordinates3.y1),
color2: robot.getPixelColor(cordinates3.x2,cordinates3.y2),
color3: robot.getPixelColor(cordinates3.x3,cordinates3.y3),
color4: robot.getPixelColor(cordinates3.x4,cordinates3.y4),
color5: robot.getPixelColor(cordinates3.x5,cordinates3.y5),
color6: robot.getPixelColor(cordinates3.x6,cordinates3.y6)
}
const hexToRgb = (hex) => {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
}
console.log(hexToRgb(colors1.color1));
console.log(colors2);
console.log(color3);
// get colors from screen areas.
/*
---------------------------------
|*******************************|
|*******************************|
|** **|
|** **|
|** **|
|** **|
|** **|
---------------------------------
| |
| |
--------------
| | | |
--------------
* işaretleri renklerin alınacağı yerler.
*/