Skip to content

Commit 8bd2440

Browse files
Test update 2 (#32)
* Update code for custom button configurations 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. * Test update to fix scaling --------- Co-authored-by: oussama mrissa <oussama.mrissa@sesame.com.tn>
1 parent e755428 commit 8bd2440

20 files changed

+683
-148
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ bin/
2424
# project
2525
bobrust.properties
2626
hs_err_pid*.log
27+
button_config.json

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ project.ext {
2020
gsonVersion = '2.10.1'
2121

2222
majorVersion = '0'
23-
minorVersion = '5'
23+
minorVersion = '6'
2424
}
2525

2626
version = "${majorVersion}.${minorVersion}.${getBuildId()}" + ""
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)