diff --git a/.gradle/6.6.1/executionHistory/executionHistory.bin b/.gradle/6.6.1/executionHistory/executionHistory.bin index f3a4a53..d1c665f 100644 Binary files a/.gradle/6.6.1/executionHistory/executionHistory.bin and b/.gradle/6.6.1/executionHistory/executionHistory.bin differ diff --git a/.gradle/6.6.1/executionHistory/executionHistory.lock b/.gradle/6.6.1/executionHistory/executionHistory.lock index 8956d23..28a4599 100644 Binary files a/.gradle/6.6.1/executionHistory/executionHistory.lock and b/.gradle/6.6.1/executionHistory/executionHistory.lock differ diff --git a/.gradle/6.6.1/fileHashes/fileHashes.bin b/.gradle/6.6.1/fileHashes/fileHashes.bin index 2210c86..70bca17 100644 Binary files a/.gradle/6.6.1/fileHashes/fileHashes.bin and b/.gradle/6.6.1/fileHashes/fileHashes.bin differ diff --git a/.gradle/6.6.1/fileHashes/fileHashes.lock b/.gradle/6.6.1/fileHashes/fileHashes.lock index 1412b6e..bcaadb5 100644 Binary files a/.gradle/6.6.1/fileHashes/fileHashes.lock and b/.gradle/6.6.1/fileHashes/fileHashes.lock differ diff --git a/.gradle/6.6.1/javaCompile/classAnalysis.bin b/.gradle/6.6.1/javaCompile/classAnalysis.bin index 05f2a39..db8a406 100644 Binary files a/.gradle/6.6.1/javaCompile/classAnalysis.bin and b/.gradle/6.6.1/javaCompile/classAnalysis.bin differ diff --git a/.gradle/6.6.1/javaCompile/javaCompile.lock b/.gradle/6.6.1/javaCompile/javaCompile.lock index 7c8ea72..a83402f 100644 Binary files a/.gradle/6.6.1/javaCompile/javaCompile.lock and b/.gradle/6.6.1/javaCompile/javaCompile.lock differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index d2604e9..e4400f8 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/build/classes/java/main/Parser.class b/build/classes/java/main/Parser.class index 5ae4b0b..e332e5c 100644 Binary files a/build/classes/java/main/Parser.class and b/build/classes/java/main/Parser.class differ diff --git a/build/classes/java/main/Rect.class b/build/classes/java/main/Rect.class index 03ec2af..d0704a5 100644 Binary files a/build/classes/java/main/Rect.class and b/build/classes/java/main/Rect.class differ diff --git a/build/libs/Image-to-code-converter-for-mindustry-6.0-logic-blocks.jar b/build/libs/Image-to-code-converter-for-mindustry-6.0-logic-blocks.jar index b10d5eb..3d67eb3 100644 Binary files a/build/libs/Image-to-code-converter-for-mindustry-6.0-logic-blocks.jar and b/build/libs/Image-to-code-converter-for-mindustry-6.0-logic-blocks.jar differ diff --git a/build/libs/image.png b/build/libs/image.png index e5f450c..31fbc03 100644 Binary files a/build/libs/image.png and b/build/libs/image.png differ diff --git a/build/libs/output2.txt b/build/libs/output2.txt deleted file mode 100644 index e69de29..0000000 diff --git a/build/libs/output3.txt b/build/libs/output3.txt deleted file mode 100644 index e69de29..0000000 diff --git a/build/libs/output4.txt b/build/libs/output4.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/main/java/Parser.java b/src/main/java/Parser.java index 2c819a9..8099c00 100644 --- a/src/main/java/Parser.java +++ b/src/main/java/Parser.java @@ -9,6 +9,7 @@ import mindustry.game.Schematics; import mindustry.world.Block; +import java.awt.*; import java.util.ArrayList; import java.util.*; import java.awt.image.BufferedImage; @@ -31,7 +32,6 @@ public static void main(String[] args) { } } try { - String baka; FileWriter writer = new FileWriter("schematic.txt", false); @@ -49,10 +49,10 @@ public static void main(String[] args) { if (h > 176) { h = 176; } - int[][] pictureR = new int[w][h]; - int[][] pictureG = new int[w][h]; - int[][] pictureB = new int[w][h]; + + int[][] yChecker = new int[w][h]; + int[][] rgb = new int[w][h]; int x = 0; @@ -61,11 +61,9 @@ public static void main(String[] args) { while (x < w) { y = 0; while (y < h) { - int rgb = bi.getRGB(x, y); - colors.add(rgb); - pictureR[x][y] = (rgb >> 16) & 0xFF; - pictureG[x][y] = (rgb >> 8) & 0xFF; - pictureB[x][y] = (rgb) & 0xFF; + int baka = bi.getRGB(x, y); + rgb[x][h - 1 - y] = baka; + colors.add(baka); y++; } x++; @@ -79,41 +77,54 @@ public static void main(String[] args) { lastY = 0; while (y < h) { if (lastY != y) { - if (bi.getRGB(x, y) == bi.getRGB(x, lastY)) { + if (rgb[x][y] == rgb[x][lastY]) { counter++; yChecker[x][y] = -1; + } else { yChecker[x][lastY] = counter; counter = 1; lastY = y; } } - y++; } yChecker[x][lastY] = counter; counter = 1; x++; } + System.out.println(); + x = 0; + while (x < w) { + y = 0; + while (y < h) { + if (yChecker[x][y] != -1) { + rects.add(new Rect(x, y, yChecker[x][y] + 1, rgb[x][y])); + } + y++; + } + x++; + } System.out.println("graphic primetives finding succsess"); + System.out.println(rects.size()); - + int processorId = 0; String[][] sch = new String[8][8]; sch[0][0] = ""; - int maxColor = getBGcolor(rects, colors); - rects = rmColor(maxColor, rects); + //int maxColor = getBGcolor(rects, colors); + //rects = rmColor(maxColor, rects); int schx = 0; int schy = 0; int stringChecker = 2; - int PFChecker = 1; - String TColor = null; - //FileWriter writerC = new FileWriter("COut"+PFChecker+".txt", false); - //writerC.append("draw clear " + ((maxColor >> 16) & 0xFF) + " " + ((maxColor >> 8) & 0xFF) + " " + ((maxColor) & 0xFF) + " 255 0 0\n"); - sch[schx][schy] += "draw clear " + ((maxColor >> 16) & 0xFF) + " " + ((maxColor >> 8) & 0xFF) + " " + ((maxColor) & 0xFF) + " 255 0 0\n"; + String TColor; + int id = 1; + //sch[schx][schy] += "draw clear " + ((maxColor >> 16) & 0xFF) + " " + ((maxColor >> 8) & 0xFF) + " " + ((maxColor) & 0xFF) + " 255 0 0\n"; + stringChecker++; + stringChecker++; + sch[0][0] += "read id cell1 1\njump 0 notEqual id " + id + "\n"; for (int c : colors) { TColor = ("draw color " + ((c >> 16) & 0xFF) + " " + ((c >> 8) & 0xFF) + " " + ((c) & 0xFF) + " 255 0 0\n"); stringChecker++; - //writerC.append(TColor); sch[schx][schy] += TColor; for (Rect r : getColor(c, rects)) { sch[schx][schy] += "draw rect " + r.x + " " + r.y + " 1 " + r.z + " 0 0\n"; @@ -122,32 +133,21 @@ public static void main(String[] args) { stringChecker++; sch[schx][schy] += "drawflush display1\n"; } - if (stringChecker == 999 && schx == 0 && schy == 0) { - stringChecker = 2; - sch[schx][schy] += "drawflush display1\nend"; - PFChecker++; - schx++; - if (schx > 7) { - schy++; - schx = 0; - } - sch[schx][schy] = ""; - sch[schx][schy] += TColor; - } - if (stringChecker == 1000 || stringChecker > 999) { - stringChecker = 2; - sch[schx][schy] += "drawflush display1"; - PFChecker++; + if (stringChecker > 996) { + stringChecker = 3; + id++; + sch[schx][schy] += "drawflush display1\nwrite " + id + " cell1 1"; schx++; if (schx > 7) { schy++; schx = 0; } - sch[schx][schy] = ""; + sch[schx][schy] = "read id cell1 1\njump 0 notEqual id " + id + "\n"; sch[schx][schy] += TColor; } } } + sch[schx][schy] += "drawflush display1"; writer.append(generate(sch)); writer.flush();