Skip to content
This repository has been archived by the owner on Jan 25, 2021. It is now read-only.

Commit

Permalink
Вроде даже работает
Browse files Browse the repository at this point in the history
  • Loading branch information
nekonya3031 committed Dec 13, 2020
1 parent df688d1 commit 148efe0
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 37 deletions.
Binary file modified .gradle/6.6.1/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified .gradle/6.6.1/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified .gradle/6.6.1/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/6.6.1/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/6.6.1/javaCompile/classAnalysis.bin
Binary file not shown.
Binary file modified .gradle/6.6.1/javaCompile/javaCompile.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified build/classes/java/main/Parser.class
Binary file not shown.
Binary file modified build/classes/java/main/Rect.class
Binary file not shown.
Binary file not shown.
Binary file modified build/libs/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file removed build/libs/output2.txt
Empty file.
Empty file removed build/libs/output3.txt
Empty file.
Empty file removed build/libs/output4.txt
Empty file.
74 changes: 37 additions & 37 deletions src/main/java/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,7 +32,6 @@ public static void main(String[] args) {
}
}
try {
String baka;

FileWriter writer = new FileWriter("schematic.txt", false);

Expand All @@ -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;
Expand All @@ -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++;
Expand All @@ -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";
Expand All @@ -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();
Expand Down

0 comments on commit 148efe0

Please sign in to comment.