Skip to content

Commit 8cd13db

Browse files
mrissaoussamaKariaro
authored andcommitted
Test
currently there needs to be a config json so makers can appear properly. (bug: markers appear incorrectly if you try to setup again, must be the offset from the red border) - added "done" button during marker or region selection -added openarrowmarker in region selection dialog -made bobrustpalette receive a screenshot of the color area, split it into 4 by 16 grid and map the coords relative to screen. getSizeButton is changed to work with the brush size limit of 100 -palette generator is unused now. - made the coordinate record in its own file -made circleCache load circle_config.json and create one with defaults if it doesn't exist. made for easier testing. - added config file related functions to ApplicationWindow. Thanks for the developer for explaining and helping me make this work.
1 parent e755428 commit 8cd13db

File tree

12 files changed

+605
-129
lines changed

12 files changed

+605
-129
lines changed

button_config.json

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"clearCanvas": {
3+
"x": 38,
4+
"y": 79,
5+
"valid": true
6+
},
7+
"saveToDesktop": {
8+
"x": 97,
9+
"y": 81,
10+
"valid": true
11+
},
12+
"saveImage": {
13+
"x": 239,
14+
"y": 16,
15+
"valid": true
16+
},
17+
"clearRotation": {
18+
"x": 257,
19+
"y": 86,
20+
"valid": true
21+
},
22+
"tool_paintBrush": {
23+
"x": 1558,
24+
"y": 177,
25+
"valid": true
26+
},
27+
"brush_circle": {
28+
"x": 1680,
29+
"y": 182,
30+
"valid": true
31+
},
32+
"brush_square": {
33+
"x": 1558,
34+
"y": 294,
35+
"valid": true
36+
},
37+
"size_1": {
38+
"x": 1679,
39+
"y": 233,
40+
"valid": true
41+
},
42+
"size_32": {
43+
"x": 1821,
44+
"y": 233,
45+
"valid": true
46+
},
47+
"opacity_0": {
48+
"x": 1679,
49+
"y": 317,
50+
"valid": true
51+
},
52+
"opacity_1": {
53+
"x": 1821,
54+
"y": 316,
55+
"valid": true
56+
},
57+
"color_topLeft": {
58+
"x": 1590,
59+
"y": 478,
60+
"valid": true
61+
},
62+
"color_botRight": {
63+
"x": 1873,
64+
"y": 894,
65+
"valid": true
66+
},
67+
"focus": {
68+
"x": 1436,
69+
"y": 925,
70+
"valid": true
71+
},
72+
"colorPreview": {
73+
"x": 1436,
74+
"y": 925,
75+
"valid": true
76+
}
77+
}

circle_config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"CIRCLE_0":8,"CIRCLE_1":16,"CIRCLE_2":26,"CIRCLE_3":36,"CIRCLE_4":46,"CIRCLE_5":56,"CIRCLE_6":70}
Lines changed: 40 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,75 @@
11
package com.bobrust.generator;
22

3-
class CircleCache {
4-
private static final Scanline[] CIRCLE_0 = generateCircle(1);
5-
private static final Scanline[] CIRCLE_1 = generateCircle(4);
6-
private static final Scanline[] CIRCLE_2 = generateCircle(8);
7-
private static final Scanline[] CIRCLE_3 = generateCircle(12);
8-
private static final Scanline[] CIRCLE_4 = generateCircle(19);
9-
private static final Scanline[] CIRCLE_5 = generateCircle(26); // 25 // Might be larger
3+
import com.bobrust.robot.BobRustPainter;
4+
import org.apache.logging.log4j.LogManager;
5+
import org.apache.logging.log4j.Logger;
6+
7+
class CircleCache {
8+
private static final Logger LOGGER = LogManager.getLogger(BobRustPainter.class);
9+
10+
private static final Scanline[] CIRCLE_0;
11+
private static final Scanline[] CIRCLE_1;
12+
private static final Scanline[] CIRCLE_2;
13+
private static final Scanline[] CIRCLE_3;
14+
private static final Scanline[] CIRCLE_4;
15+
private static final Scanline[] CIRCLE_5;
1016

11-
public static final Scanline[][] CIRCLE_CACHE = { CIRCLE_0, CIRCLE_1, CIRCLE_2, CIRCLE_3, CIRCLE_4, CIRCLE_5 };
17+
public static final Scanline[][] CIRCLE_CACHE;
1218
public static final int[] CIRCLE_CACHE_LENGTH;
13-
14-
static {
19+
20+
// Default circle values
21+
public static final int DEFAULT_CIRCLE_0_VALUE = 3;
22+
public static final int DEFAULT_CIRCLE_1_VALUE = 6;
23+
public static final int DEFAULT_CIRCLE_2_VALUE = 12;
24+
public static final int DEFAULT_CIRCLE_3_VALUE = 25;
25+
public static final int DEFAULT_CIRCLE_4_VALUE = 50;
26+
public static final int DEFAULT_CIRCLE_5_VALUE = 100;
27+
28+
static {
29+
CIRCLE_0 = generateCircle(DEFAULT_CIRCLE_0_VALUE);
30+
CIRCLE_1 = generateCircle(DEFAULT_CIRCLE_1_VALUE);
31+
CIRCLE_2 = generateCircle(DEFAULT_CIRCLE_2_VALUE);
32+
CIRCLE_3 = generateCircle(DEFAULT_CIRCLE_3_VALUE);
33+
CIRCLE_4 = generateCircle(DEFAULT_CIRCLE_4_VALUE);
34+
CIRCLE_5 = generateCircle(DEFAULT_CIRCLE_5_VALUE);
35+
CIRCLE_CACHE = new Scanline[][] {
36+
CIRCLE_0, CIRCLE_1, CIRCLE_2, CIRCLE_3, CIRCLE_4, CIRCLE_5
37+
};
1538
CIRCLE_CACHE_LENGTH = new int[CIRCLE_CACHE.length];
1639
for (int i = 0; i < CIRCLE_CACHE.length; i++) {
1740
CIRCLE_CACHE_LENGTH[i] = CIRCLE_CACHE[i].length;
1841
}
1942
}
20-
21-
/*public static void main(String[] args) {
22-
// 1, 4, 8, 12, 19, 25
23-
// 18 full match but 19 matches area
24-
// 24 full match but 25 matches area
25-
generateCircle(24);
26-
}*/
27-
43+
2844
private static Scanline[] generateCircle(int size) {
45+
LOGGER.info("circle size " +size);
2946
boolean[] grid = new boolean[size * size];
3047
for (int i = 0; i < size * size; i++) {
3148
double px = (int) (i % size) + 0.5;
3249
double py = (int) (i / size) + 0.5;
3350
double x = (px / (double) size) * 2.0 - 1;
3451
double y = (py / (double) size) * 2.0 - 1;
35-
36-
double magnitudeSqr = x*x + y*y;
52+
53+
double magnitudeSqr = x * x + y * y;
3754
grid[i] = magnitudeSqr <= 1;
3855
}
39-
40-
/*{
41-
BufferedImage bi = new BufferedImage(size, size, BufferedImage.TYPE_INT_RGB);
42-
int[] pixels = ((DataBufferInt) bi.getRaster().getDataBuffer()).getData();
43-
for (int i = 0; i < grid.length; i++) {
44-
pixels[i] = grid[i] ? 0x000000 : 0xffffff;
45-
}
46-
47-
DebugUtil.debugShowImage(bi, 13);
48-
}*/
49-
56+
5057
Scanline[] scanlines = new Scanline[size];
5158
for (int i = 0; i < size; i++) {
5259
int start = size;
5360
int end = 0;
5461
for (int j = 0; j < size; j++) {
5562
if (grid[i * size + j]) {
5663
start = Math.min(start, j);
57-
end = Math.max(end, j );
64+
end = Math.max(end, j);
5865
}
5966
}
60-
67+
6168
if (start <= end) {
6269
int off = size / 2;
6370
scanlines[i] = new Scanline(i - off, start - off, end - off);
6471
}
6572
}
66-
67-
/*{
68-
int off = size / 2;
69-
BufferedImage bi = new BufferedImage(size, size, BufferedImage.TYPE_INT_RGB);
70-
int[] pixels = ((DataBufferInt) bi.getRaster().getDataBuffer()).getData();
71-
Arrays.fill(pixels, 0xffffff);
72-
for (Scanline line : scanlines) {
73-
for (int x = line.x1; x <= line.x2; x++) {
74-
pixels[(line.y + off) * size + (x + off)] = 0x000000;
75-
}
76-
}
77-
DebugUtil.debugShowImage(bi, 13);
78-
}*/
79-
8073
return scanlines;
8174
}
8275
}

0 commit comments

Comments
 (0)