Updated DivaBot for compatibility with new DLC. Fixed finder ":"

incompatibility.
secondmonitor 03
sigonasr2 4 years ago
parent 3fcd42dd20
commit 530c963014
  1. BIN
      DivaBot/DivaBot.jar
  2. BIN
      DivaBot/TypeFace_API.jar
  3. 8
      DivaBot/calibration_data.txt
  4. BIN
      DivaBot/capture.png
  5. BIN
      DivaBot/capture_2.png
  6. BIN
      DivaBot/capture_3.png
  7. BIN
      DivaBot/capture_4.png
  8. BIN
      DivaBot/capture_5.png
  9. 14
      DivaBot/colorData
  10. 12
      DivaBot/config.txt
  11. 52
      DivaBot/src/sig/Calibrator.java
  12. 44
      DivaBot/src/sig/Display.java
  13. 51
      DivaBot/src/sig/DisplayManager.java
  14. 2
      DivaBot/src/sig/ListTransferHandler.java
  15. 40
      DivaBot/src/sig/MyRobot.java
  16. 35
      DivaBot/src/sig/ReloadSong.java
  17. 6
      DivaBot/src/sig/SongData.java
  18. 2
      DivaBot/src/sig/SongInfo.java
  19. 431
      DivaBot/src/sig/TypeFace.java
  20. BIN
      DivaBot/test.png
  21. BIN
      Release/DivaBot/DivaBot/DivaBot.jar
  22. 18
      Release/DivaBot/DivaBot/colorData
  23. BIN
      Release/DivaBot/DivaBot/reloadSong.png
  24. BIN
      Release/DivaBot02.zip

Binary file not shown.

Binary file not shown.

@ -1,4 +1,4 @@
438
290
1329
787
419
206
1642
889

Binary file not shown.

Before

Width:  |  Height:  |  Size: 677 KiB

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 677 KiB

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 677 KiB

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 675 KiB

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 675 KiB

After

Width:  |  Height:  |  Size: 1.2 MiB

@ -162,3 +162,17 @@ Star Story:1808285827,3434600865,4320953611
夢の続き:9980651028,9269054443,7923490029
MEGANE:12097703860,7865703856,8089571528
Change me:6946360046,4571504089,2910280226
アドレサンス:5458033068,4389022230,4212580841
グリーンライツセレナーデ:6422553300,6622495000,6942409156
サウンド:2350288995,3725672868,3350500213
Stay with me:6858394047,5138098343,3976139800
ドラマツルギー:9364452247,9429738184,9396666719
Nyanyanyanyanyanyanya!:8284558575,7067572325,6713348796
巴里映画少女:7543881170,6294797933,6122764603
ファインダー (DSLR remix - re-COLON-edit):5687636652,7373735766,7988148878
フキゲンワルツ:7878892274,8044206152,6207005607
Promise:4021169803,4900248262,6497913358
星屑ユートピア:3370014582,2298015215,925945505
マージナル:7836108651,8174436060,8267809525
Last Night, Good Night:3265412964,4528174454,4889449827
Leia:6765406279,5114086294,4206059909

@ -1,11 +1,11 @@
DISPLAYDATA -16776961*-13369549*94*Microsoft YaHei UI Bold*600*150*5000*Song Title (Japanese+Romanized)*176*80*~-16776961*-13369549*24*Gulim*400*40*300*Overall Rating|Song Title (Romanized)|FC Count*176*240*
LAST_HEIGHT 150
DISPLAYDATA -16776961*-13369549*94*Microsoft YaHei UI Bold*600*150*5000*Song Title (Japanese+Romanized)*176*80**~-16776961*-13369549*24*Gulim*400*40*1000*Overall Rating|Song Title (Romanized)|FC Count*176*240**~-16776961*-13369549*24*Dialog.italic*400*40*300*Song Title (Japanese+Romanized+ENG)*0*0*Header: *
LAST_HEIGHT 40
WIDTH 1127
HEIGHT 732
BACKGROUND -6697729
LAST_TEXT -13369549
LAST_FONT Microsoft YaHei UI Bold
LAST_FONTSIZE 94
LAST_FONT Dialog.italic
LAST_FONTSIZE 24
LAST_BACKGROUND -16776961
LAST_WIDTH 600
LAST_DELAY 5000
LAST_WIDTH 400
LAST_DELAY 300

@ -9,7 +9,6 @@ import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import sig.utils.FileUtils;
@ -19,10 +18,6 @@ public class Calibrator{
Calibrator() throws IOException, InterruptedException {
boolean failed=false;
int x = Math.min(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x);
int y = Math.min(MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.y);
int width = (Math.max(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x)-Math.min(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x));
int height = (Math.max(MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.y)-Math.min(MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.y));
if (MyRobot.STARTDRAG.x>MyRobot.ENDDRAG.x) {
int xTemp=MyRobot.STARTDRAG.x;
@ -35,11 +30,6 @@ public class Calibrator{
MyRobot.ENDDRAG.y=yTemp;
}
/*Rectangle currentPointer = new Rectangle(
x,y,
(int)Math.floor(x+width*0.03984375d),
(int)Math.floor(y+height*0.30833333333333333333333333333333d));
calibrationline=currentPointer;*/
img = MyRobot.MYROBOT.getSizedCapture(new Rectangle(0,0,MyRobot.screenSize.width,MyRobot.screenSize.height));
ImageIO.write(img.getSubimage(MyRobot.STARTDRAG.x,MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.x-MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.y-MyRobot.STARTDRAG.y),"png",new File("capture_5.png"));
failed=CalibrationStage1();
@ -78,11 +68,6 @@ public class Calibrator{
}
MyRobot.FRAME.setAlwaysOnTop(true);
// failed=CalibrationStage3(p);
// if (failed) {return;}
// failed=CalibrationStage4(p);
// if (failed) {return;}
//MyRobot.CALIBRATIONSTATUS="First calibration set done: X"+(x-MyRobot.STARTDRAG.x)+" Y"+(y-MyRobot.STARTDRAG.y);
img = MyRobot.MYROBOT.getSizedCapture(new Rectangle(0,0,MyRobot.screenSize.width,MyRobot.screenSize.height));
ImageIO.write(img.getSubimage(MyRobot.STARTDRAG.x,MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.x-MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.y-MyRobot.STARTDRAG.y),"png",new File("capture_5.png"));
FileUtils.deleteFile("calibration_data.txt");
@ -96,15 +81,11 @@ public class Calibrator{
boolean calibrated=false;
int MAXTRIES=10000;
MyRobot.CALIBRATIONSTATUS="Calibration Stage 1...";
//ImageIO.write(MYROBOT.getSizedCapture(new Rectangle(x,y,width,height)),"png",new File("capture.png"));
//BufferedImage currentScreen = MyRobot.MYROBOT.getSizedCapture(new Rectangle(0,0,MyRobot.screenSize.width,MyRobot.screenSize.height));
ImageIO.write(img.getSubimage(MyRobot.STARTDRAG.x,MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.x-MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.y-MyRobot.STARTDRAG.y),"png",new File("capture.png"));
while (!calibrated&&MAXTRIES>0) {
//Try moving left until the difference is too high or the colors are not right anymore.
MyRobot.STARTDRAG.x-=1;
//BufferedImage pixel = MYROBOT.getSizedCapture(new Rectangle(MyRobot.STARTDRAG.x,MyRobot.STARTDRAG.y,1,1));
BufferedImage miniImg = img.getSubimage(MyRobot.STARTDRAG.x,MyRobot.STARTDRAG.y,1,1);
//ImageIO.write(miniImg,"png",new File("capture_"+System.nanoTime()+".png"));
Color col = new Color(miniImg.getRGB(0, 0));
System.out.println("Checking "+col);
if (!(col.getRed()>=5&&col.getRed()<=40&&
@ -126,16 +107,11 @@ public class Calibrator{
boolean calibrated=false;
int MAXTRIES=10000;
MyRobot.CALIBRATIONSTATUS="Calibration Stage 2...";
//ImageIO.write(MYROBOT.getSizedCapture(new Rectangle(x,y,width,height)),"png",new File("capture.png"));
//BufferedImage currentScreen = MYROBOT.getSizedCapture(new Rectangle(MyRobot.STARTDRAG.x,MyRobot.STARTDRAG.y,MyRobot.ENDDRAG,height));
//BufferedImage currentScreen = MyRobot.MYROBOT.getSizedCapture(new Rectangle(0,0,MyRobot.screenSize.width,MyRobot.screenSize.height));
ImageIO.write(img.getSubimage(MyRobot.STARTDRAG.x,MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.x-MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.y-MyRobot.STARTDRAG.y),"png",new File("capture_2.png"));
while (!calibrated&&MAXTRIES>0) {
//Try moving left until the difference is too high or the colors are not right anymore.
MyRobot.STARTDRAG.y-=1;
//currentScreen.setRGB(MyRobot.STARTDRAG.x,MyRobot.STARTDRAG.y, new Color(0,0,0).getRGB());
BufferedImage miniImg = img.getSubimage(MyRobot.STARTDRAG.x,MyRobot.STARTDRAG.y,1,1);
//ImageIO.write(miniImg,"png",new File("capture_2_"+System.nanoTime()+".png"));
Color col = new Color(miniImg.getRGB(0, 0));
System.out.println("Checking "+col);
if (!(col.getRed()>=5&&col.getRed()<=100&&
@ -156,15 +132,11 @@ public class Calibrator{
boolean calibrated=false;
int MAXTRIES=10000;
MyRobot.CALIBRATIONSTATUS="Calibration Stage 3...";
//ImageIO.write(MYROBOT.getSizedCapture(new Rectangle(x,y,width,height)),"png",new File("capture.png"));
//BufferedImage currentScreen = MyRobot.MYROBOT.getSizedCapture(new Rectangle(0,0,MyRobot.screenSize.width,MyRobot.screenSize.height));
ImageIO.write(img.getSubimage(MyRobot.STARTDRAG.x,MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.x-MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.y-MyRobot.STARTDRAG.y),"png",new File("capture_3.png"));
while (!calibrated&&MAXTRIES>0) {
//Try moving left until the difference is too high or the colors are not right anymore.
MyRobot.ENDDRAG.x+=1;
//BufferedImage pixel = MYROBOT.getSizedCapture(new Rectangle(MyRobot.ENDDRAG.x,MyRobot.ENDDRAG.y,1,1));
BufferedImage miniImg = img.getSubimage(MyRobot.ENDDRAG.x,MyRobot.ENDDRAG.y,1,1);
//ImageIO.write(miniImg,"png",new File("capture_3_"+System.nanoTime()+".png"));
Color col = new Color(miniImg.getRGB(0, 0));
System.out.println("Checking "+col);
if (!(col.getRed()>=40&&col.getRed()<=90&&
@ -186,16 +158,11 @@ public class Calibrator{
boolean calibrated=false;
int MAXTRIES=10000;
MyRobot.CALIBRATIONSTATUS="Calibration Stage 4...";
//ImageIO.write(MYROBOT.getSizedCapture(new Rectangle(x,y,width,height)),"png",new File("capture.png"));
//BufferedImage currentScreen = MYROBOT.getSizedCapture(new Rectangle(MyRobot.ENDDRAG.x,MyRobot.ENDDRAG.y,MyRobot.ENDDRAG,height));
//BufferedImage currentScreen = MyRobot.MYROBOT.getSizedCapture(new Rectangle(0,0,MyRobot.screenSize.width,MyRobot.screenSize.height));
ImageIO.write(img.getSubimage(MyRobot.STARTDRAG.x,MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.x-MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.y-MyRobot.STARTDRAG.y),"png",new File("capture_4.png"));
while (!calibrated&&MAXTRIES>0) {
//Try moving left until the difference is too high or the colors are not right anymore.
MyRobot.ENDDRAG.y+=1;
//currentScreen.setRGB(MyRobot.ENDDRAG.x,MyRobot.ENDDRAG.y, new Color(0,0,0).getRGB());
BufferedImage miniImg = img.getSubimage(MyRobot.ENDDRAG.x,MyRobot.ENDDRAG.y,1,1);
//ImageIO.write(miniImg,"png",new File("capture_4_"+System.nanoTime()+".png"));
Color col = new Color(miniImg.getRGB(0, 0));
System.out.println("Checking "+col);
if (!(col.getRed()>=40&&col.getRed()<=90&&
@ -216,16 +183,12 @@ public class Calibrator{
boolean calibrated=false;
int MAXTRIES=100;
MyRobot.CALIBRATIONSTATUS="Calibration Stage 5...";
//ImageIO.write(MYROBOT.getSizedCapture(new Rectangle(x,y,width,height)),"png",new File("capture.png"));
//BufferedImage currentScreen = MyRobot.MYROBOT.getSizedCapture(new Rectangle(0,0,MyRobot.screenSize.width,MyRobot.screenSize.height));
ImageIO.write(img.getSubimage(MyRobot.STARTDRAG.x,MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.x-MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.y-MyRobot.STARTDRAG.y),"png",new File("capture.png"));
while (!calibrated&&MAXTRIES>0) {
//Try moving left until the difference is too high or the colors are not right anymore.
MyRobot.STARTDRAG.x+=1;
//BufferedImage pixel = MYROBOT.getSizedCapture(new Rectangle(MyRobot.STARTDRAG.x,MyRobot.STARTDRAG.y,1,1));
for (int i=0;i<100;i++) {
BufferedImage miniImg = img.getSubimage(MyRobot.STARTDRAG.x,MyRobot.STARTDRAG.y+i,1,1);
//ImageIO.write(miniImg,"png",new File("capture_"+System.nanoTime()+".png"));
Color col = new Color(miniImg.getRGB(0, 0));
System.out.println("Checking "+col);
if ((col.getRed()>=5&&col.getRed()<=75&&
@ -233,7 +196,6 @@ public class Calibrator{
col.getBlue()>=180&&col.getBlue()<=250)) {
//This is the max X. Calibration on this side good.
MyRobot.STARTDRAG.y=MyRobot.STARTDRAG.y+i;
//MyRobot.STARTDRAG.x--;
System.out.println("End at "+MyRobot.STARTDRAG.x);
return false;
}
@ -248,17 +210,12 @@ public class Calibrator{
boolean calibrated=false;
int MAXTRIES=100;
MyRobot.CALIBRATIONSTATUS="Calibration Stage 6...";
//ImageIO.write(MYROBOT.getSizedCapture(new Rectangle(x,y,width,height)),"png",new File("capture.png"));
//BufferedImage currentScreen = MYROBOT.getSizedCapture(new Rectangle(MyRobot.STARTDRAG.x,MyRobot.STARTDRAG.y,MyRobot.ENDDRAG,height));
//BufferedImage currentScreen = MyRobot.MYROBOT.getSizedCapture(new Rectangle(0,0,MyRobot.screenSize.width,MyRobot.screenSize.height));
ImageIO.write(img.getSubimage(MyRobot.STARTDRAG.x,MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.x-MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.y-MyRobot.STARTDRAG.y),"png",new File("capture_2.png"));
while (!calibrated&&MAXTRIES>0) {
//Try moving left until the difference is too high or the colors are not right anymore.
MyRobot.STARTDRAG.y+=1;
//currentScreen.setRGB(MyRobot.STARTDRAG.x,MyRobot.STARTDRAG.y, new Color(0,0,0).getRGB());
for (int i=0;i<100;i++) {
BufferedImage miniImg = img.getSubimage(MyRobot.STARTDRAG.x+i,MyRobot.STARTDRAG.y,1,1);
//ImageIO.write(miniImg,"png",new File("capture_2_"+System.nanoTime()+".png"));
Color col = new Color(miniImg.getRGB(0, 0));
System.out.println("Checking "+col);
if ((col.getRed()>=5&&col.getRed()<=100&&
@ -280,16 +237,12 @@ public class Calibrator{
boolean calibrated=false;
int MAXTRIES=100;
MyRobot.CALIBRATIONSTATUS="Calibration Stage 7...";
//ImageIO.write(MYROBOT.getSizedCapture(new Rectangle(x,y,width,height)),"png",new File("capture.png"));
//BufferedImage currentScreen = MyRobot.MYROBOT.getSizedCapture(new Rectangle(0,0,MyRobot.screenSize.width,MyRobot.screenSize.height));
ImageIO.write(img.getSubimage(MyRobot.STARTDRAG.x,MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.x-MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.y-MyRobot.STARTDRAG.y),"png",new File("capture_3.png"));
while (!calibrated&&MAXTRIES>0) {
//Try moving left until the difference is too high or the colors are not right anymore.
MyRobot.ENDDRAG.x-=1;
//BufferedImage pixel = MYROBOT.getSizedCapture(new Rectangle(MyRobot.ENDDRAG.x,MyRobot.ENDDRAG.y,1,1));
for (int i=0;i<100;i++) {
BufferedImage miniImg = img.getSubimage(MyRobot.ENDDRAG.x,MyRobot.ENDDRAG.y-i,1,1);
//ImageIO.write(miniImg,"png",new File("capture_3_"+System.nanoTime()+".png"));
Color col = new Color(miniImg.getRGB(0, 0));
System.out.println("Checking "+col);
if ((col.getRed()>=40&&col.getRed()<=90&&
@ -312,17 +265,12 @@ public class Calibrator{
boolean calibrated=false;
int MAXTRIES=100;
MyRobot.CALIBRATIONSTATUS="Calibration Stage 8...";
//ImageIO.write(MYROBOT.getSizedCapture(new Rectangle(x,y,width,height)),"png",new File("capture.png"));
//BufferedImage currentScreen = MYROBOT.getSizedCapture(new Rectangle(MyRobot.ENDDRAG.x,MyRobot.ENDDRAG.y,MyRobot.ENDDRAG,height));
//BufferedImage currentScreen = MyRobot.MYROBOT.getSizedCapture(new Rectangle(0,0,MyRobot.screenSize.width,MyRobot.screenSize.height));
ImageIO.write(img.getSubimage(MyRobot.STARTDRAG.x,MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.x-MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.y-MyRobot.STARTDRAG.y),"png",new File("capture_4.png"));
while (!calibrated&&MAXTRIES>0) {
//Try moving left until the difference is too high or the colors are not right anymore.
MyRobot.ENDDRAG.y-=1;
//currentScreen.setRGB(MyRobot.ENDDRAG.x,MyRobot.ENDDRAG.y, new Color(0,0,0).getRGB());
for (int i=0;i<100;i++) {
BufferedImage miniImg = img.getSubimage(MyRobot.ENDDRAG.x-i,MyRobot.ENDDRAG.y,1,1);
//ImageIO.write(miniImg,"png",new File("capture_4_"+System.nanoTime()+".png"));
Color col = new Color(miniImg.getRGB(0, 0));
System.out.println("Checking "+col);
if ((col.getRed()>=40&&col.getRed()<=90&&

@ -21,6 +21,7 @@ public class Display {
int height=48;
int fontHeight=0;
int delay=10000;
String header="";
long nextUpdateTime = System.currentTimeMillis();
boolean forceUpdate=false;
String[] labels;
@ -43,6 +44,9 @@ public class Display {
labels=split[7].split("\\|");
x=Integer.parseInt(split[8]);
y=Integer.parseInt(split[9]);
if (split.length>=11) {
header=split[10];
}
}
Display() {
HashMap<String,String> config = MyRobot.p.configData;
@ -98,6 +102,7 @@ public class Display {
font = new Font("Batang",Font.PLAIN,fontSize);
}
}
header = "";
labels = new String[]{"Add a label!"};
currentText=interpretLabel(labels[cycle]);
Thread t = new Thread() {
@ -172,6 +177,7 @@ public class Display {
.append(combineLabels()).append("*")
.append(x).append("*")
.append(y).append("*")
.append(header).append("*")
.toString();
}
@ -194,55 +200,55 @@ public class Display {
if (data.bestPlayTime>System.currentTimeMillis()-10000) {
return "New Record!";
} else {
return ((data.bestPlay!=null)?data.bestPlay.display():"");
return header+((data.bestPlay!=null)?data.bestPlay.display():"No plays");
}
}
case "Overall Rating":{
if (data.ratingTime>System.currentTimeMillis()-10000) {
return "Rating up! "+data.lastRating+" -> "+data.overallrating;
} else {
return Integer.toString(data.overallrating);
return header+Integer.toString(data.overallrating);
}
}
case "Song Difficulty":{
return data.difficultyRating + " - " + fullNameDifficulty(data.difficulty);
return header+data.difficultyRating + " - " + fullNameDifficulty(data.difficulty);
}
case "Song Title (Japanese)":{
return data.songname;
return header+data.songname;
}
case "Song Title (Romanized)":{
return ((data.romanizedname.length()>0)?data.romanizedname:data.englishname);
return header+((data.romanizedname.length()>0)?data.romanizedname:data.englishname);
}
case "Song Title (Japanese+Romanized)":{
if (data.songname.equalsIgnoreCase(((data.romanizedname.length()>0)?data.romanizedname:data.englishname))) {
return data.songname;
return header+data.songname;
} else {
return (data.songname + " - " + ((data.romanizedname.length()>0)?data.romanizedname:data.englishname));
return header+(data.songname + " - " + ((data.romanizedname.length()>0)?data.romanizedname:data.englishname));
}
}
case "Song Title (English)":{
return data.englishname;
return header+data.englishname;
}
case "Song Title (Japanese+Romanized+ENG)":{
if (data.songname.equalsIgnoreCase(((data.romanizedname.length()>0)?data.romanizedname:data.englishname))) {
return data.songname;
return header+data.songname;
} else {
return (data.songname + " - " + ((data.romanizedname.length()>0)?(data.romanizedname.equalsIgnoreCase(data.englishname))?data.romanizedname:data.romanizedname+" ("+data.englishname+")":data.englishname));
return header+(data.songname + " - " + ((data.romanizedname.length()>0)?(data.romanizedname.equalsIgnoreCase(data.englishname))?data.romanizedname:data.romanizedname+" ("+data.englishname+")":data.englishname));
}
}
case "Song Artist":{
return "Artist: "+data.artist;
return header+data.artist;
}
case "Play Count":{
if (data.plays>0) {
return Integer.toString(data.plays)+" play"+((data.plays!=1)?"s":"");
return header+Integer.toString(data.plays)+" play"+((data.plays!=1)?"s":"");
} else {
return "No Plays";
}
}
case "Pass/Play Count":{
if (data.plays>0) {
return Integer.toString(data.passes) + "/" + Integer.toString(data.plays)+" play"+((data.plays!=1)?"s":"");
return header+Integer.toString(data.passes) + "/" + Integer.toString(data.plays)+" play"+((data.plays!=1)?"s":"");
}
else {
return "No Plays";
@ -250,31 +256,31 @@ public class Display {
}
case "Pass/Play Count (+%)":{
if (data.plays>0) {
return (data.passes)+"/"+(data.plays)+" play"+((data.plays!=1)?"s":"")+" "+"("+((int)(Math.floor(((float)data.passes)/data.plays*100)))+"% pass rate)";
return header+(data.passes)+"/"+(data.plays)+" play"+((data.plays!=1)?"s":"")+" "+"("+((int)(Math.floor(((float)data.passes)/data.plays*100)))+"% pass rate)";
} else {
return "No Plays";
}
}
case "FC Count":{
if (data.plays>0) {
return data.fcCount +" FC"+(data.fcCount==1?"":"s");
return header+header+data.fcCount +" FC"+(data.fcCount==1?"":"s");
} else {
return "No Plays";
}
}
case "FC Count (+%)":{
if (data.plays>0) {
return data.fcCount +" FC"+(data.fcCount==1?"":"s")+" "+((int)(Math.floor(((float)data.fcCount)/data.plays*100)))+"% FC rate";
return header+data.fcCount +" FC"+(data.fcCount==1?"":"s")+" "+((int)(Math.floor(((float)data.fcCount)/data.plays*100)))+"% FC rate";
} else {
return "No Plays";
}
}
default:{
return string;
return header+string;
}
}
} catch(NullPointerException e) {
return string;
return header+string;
}
}
private String fullNameDifficulty(String difficulty) {
@ -292,7 +298,7 @@ public class Display {
return "Extreme";
}
case "EXEX":{
return "Extra Extreme";
return "EX Extreme";
}
}
return "";

@ -48,6 +48,7 @@ public class DisplayManager extends JPanel implements MouseListener,ListSelectio
static JTextField widthInput;
static JTextField heightInput;
static JTextField delayInput;
static JTextField headerInput;
static DefaultListModel model = new DefaultListModel();
static DefaultListModel model2 = new DefaultListModel();
static JComboBox fonts;
@ -145,6 +146,8 @@ public class DisplayManager extends JPanel implements MouseListener,ListSelectio
try {
selectedDisplay.font=new Font(selectedDisplay.font.getFontName(),Font.PLAIN,Integer.parseInt(e.getDocument().getText(0, e.getDocument().getLength())));
selectedDisplay.fontSize=Integer.parseInt(e.getDocument().getText(0, e.getDocument().getLength()));
selectedDisplay.nextUpdateTime=0;
selectedDisplay.forceUpdate=true;
selectedDisplay.updateFont();
MyRobot.p.repaint();
c.setBackground(Color.WHITE);
@ -186,6 +189,8 @@ public class DisplayManager extends JPanel implements MouseListener,ListSelectio
void updateField(JTextField c, DocumentEvent e) {
try {
selectedDisplay.width=Integer.parseInt(e.getDocument().getText(0, e.getDocument().getLength()));
selectedDisplay.nextUpdateTime=0;
selectedDisplay.forceUpdate=true;
selectedDisplay.updateFont();
MyRobot.p.repaint();
c.setBackground(Color.WHITE);
@ -226,6 +231,8 @@ public class DisplayManager extends JPanel implements MouseListener,ListSelectio
void updateField(JTextField c, DocumentEvent e) {
try {
selectedDisplay.height=Integer.parseInt(e.getDocument().getText(0, e.getDocument().getLength()));
selectedDisplay.nextUpdateTime=0;
selectedDisplay.forceUpdate=true;
MyRobot.p.repaint();
c.setBackground(Color.WHITE);
} catch (NullPointerException | NumberFormatException | BadLocationException e1) {
@ -262,6 +269,8 @@ public class DisplayManager extends JPanel implements MouseListener,ListSelectio
void updateField(JTextField c, DocumentEvent e) {
try {
selectedDisplay.delay=Integer.parseInt(e.getDocument().getText(0, e.getDocument().getLength()));
selectedDisplay.nextUpdateTime=0;
selectedDisplay.forceUpdate=true;
MyRobot.p.repaint();
c.setBackground(Color.WHITE);
} catch (NullPointerException | NumberFormatException | BadLocationException e1) {
@ -297,6 +306,45 @@ public class DisplayManager extends JPanel implements MouseListener,ListSelectio
addComponent(1,9,20,1,new JLabel("Label Delay (Time between each Display)"));
addComponent(1,11,12,1,new JLabel(" "));
g.anchor=GridBagConstraints.EAST;
addComponent(7,7,1,1,new JLabel(" Header:"));
g.anchor=GridBagConstraints.WEST;
headerInput = (JTextField)addComponent(8,7,2,1,new JTextField() {
@Override
public Dimension getPreferredSize() {
return new Dimension(50,20);
}
});
headerInput.getDocument().addDocumentListener(new DocumentListener() {
void updateField(JTextField c, DocumentEvent e) {
try {
selectedDisplay.header=e.getDocument().getText(0, e.getDocument().getLength());
selectedDisplay.nextUpdateTime=0;
selectedDisplay.forceUpdate=true;
MyRobot.p.repaint();
c.setBackground(Color.WHITE);
} catch (NullPointerException | NumberFormatException | BadLocationException e1) {
c.setBackground(Color.RED);
}
}
@Override
public void insertUpdate(DocumentEvent e) {
updateField(headerInput,e);
}
@Override
public void removeUpdate(DocumentEvent e) {
updateField(headerInput,e);
}
@Override
public void changedUpdate(DocumentEvent e) {
}
});
labels.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
JScrollPane pane = new JScrollPane(labels);
@ -368,6 +416,7 @@ public class DisplayManager extends JPanel implements MouseListener,ListSelectio
MyRobot.p.configData.put("LAST_DELAY",Integer.toString(d.delay));
fontSizeInput.setText(Integer.toString(d.fontSize));
MyRobot.p.configData.put("LAST_FONTSIZE",Integer.toString(d.fontSize));
headerInput.setText(d.header);
model.clear();
model2.clear();
for (int i=0;i<d.labels.length;i++) {
@ -490,6 +539,8 @@ public class DisplayManager extends JPanel implements MouseListener,ListSelectio
public void itemStateChanged(ItemEvent e) {
if (selectedDisplay!=null) {
selectedDisplay.font=new Font(((Font)fonts.getSelectedItem()).getFontName(),Font.PLAIN,selectedDisplay.fontSize);
selectedDisplay.nextUpdateTime=0;
selectedDisplay.forceUpdate=true;
selectedDisplay.updateFont();
MyRobot.p.repaint();
}

@ -119,6 +119,8 @@ public class ListTransferHandler extends TransferHandler {
}
DisplayManager.selectedDisplay.labels=labels;
}
DisplayManager.selectedDisplay.nextUpdateTime=0;
DisplayManager.selectedDisplay.forceUpdate=true;
MyRobot.p.repaint();
//System.out.println("Selected indexes: "+Arrays.toString(indices));
for (int i=0;i<indices.length;i++) {

@ -269,19 +269,6 @@ public class MyRobot{
void BotMain() {
lastmainlooptime=System.currentTimeMillis();
while (true) {
try {
RunMainLoop();
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
private void RunMainLoop() {
try {
try {
JSONObject obj = FileUtils.readJsonFromUrl("http://45.33.13.215:4501/rating/"+USERNAME);
p.lastRating = p.overallrating;
@ -295,6 +282,19 @@ public class MyRobot{
} catch (IOException e) {
e.printStackTrace();
}
while (true) {
try {
RunMainLoop();
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
private void RunMainLoop() {
try {
if (CALIBRATION_MODE) {
if (MyRobot.calibrating) {
MyRobot.calibrating=false;
@ -845,14 +845,14 @@ public class MyRobot{
FUTURETONE=false;
} else
{
c = new Color(MYROBOT.createScreenCapture(new Rectangle(743,173,1,1)).getRGB(0, 0));
if (!onSongSelect&&(c.getRed()>=160&&c.getRed()<=185&&c.getGreen()<=15&&c.getBlue()>=170&&c.getBlue()<=200)) {
FUTURETONE=true;
onSongSelect=true;
}
//System.out.println(c);
//TODO FUTURE TONE SUPPORT DISABLED FOR NOW.
// c = new Color(MYROBOT.createScreenCapture(new Rectangle(743,173,1,1)).getRGB(0, 0));
// if (!onSongSelect&&(c.getRed()>=160&&c.getRed()<=185&&c.getGreen()<=15&&c.getBlue()>=170&&c.getBlue()<=200)) {
// FUTURETONE=true;
// onSongSelect=true;
// }
}
//System.out.println(onSongSelect+"/"+c);
//777,179 FUTURE TONE
return onSongSelect;

@ -35,16 +35,11 @@ import sig.utils.FileUtils;
public class ReloadSong extends JPanel implements ItemListener,MouseListener{
public static JFrame f = new JFrame();
public static HashMap<String,JSONObject> SONGARRAY = new HashMap<>();
public static JComboBox<JSONObject> songs;
//public static HashMap<String,JSONObject> SONGARRAY = new HashMap<>();
public static JComboBox<SongInfo> songs;
static GridBagConstraints g = new GridBagConstraints();
ReloadSong() throws IOException{
JSONObject obj = FileUtils.readJsonFromUrl("http://projectdivar.com/songs");
for (String s : JSONObject.getNames(obj)) {
JSONObject songdata = obj.getJSONObject(s);
SONGARRAY.put(songdata.getString("name"),songdata);
}
//JSONObject obj = FileUtils.readJsonFromUrl("http://projectdivar.com/songs");
f = new JFrame();
f.setIconImage(ImageIO.read(new File("cross.png")));
@ -53,18 +48,18 @@ public class ReloadSong extends JPanel implements ItemListener,MouseListener{
g.anchor=GridBagConstraints.EAST;
addComponent(1,1,2,1,new JLabel("Select correct song:"));
JSONObject[] songList = new JSONObject[SONGARRAY.size()];
SongInfo[] songList = new SongInfo[MyRobot.SONGNAMES.length];
int count = 0;
for (String s : SONGARRAY.keySet()) {
songList[count++]=SONGARRAY.get(s);
for (SongInfo s : MyRobot.SONGNAMES) {
songList[count++]=s;
}
for (int i = 0; i < count; i++)
{
for (int j = i + 1; j < count; j++) {
if (songList[i].getString("english_name").toLowerCase().compareTo(songList[j].getString("english_name").toLowerCase())>0)
if (songList[i].english_name.toLowerCase().compareTo(songList[j].english_name.toLowerCase())>0)
{
JSONObject temp = songList[i];
SongInfo temp = songList[i];
songList[i] = songList[j];
songList[j] = temp;
}
@ -98,7 +93,7 @@ public class ReloadSong extends JPanel implements ItemListener,MouseListener{
f.add(this);
f.pack();
f.setResizable(false);
f.setVisible(true);
f.setVisible(false);
}
private Component addComponent(int x, int y, int w, int h,Component component) {
g.gridx=x;
@ -124,7 +119,7 @@ public class ReloadSong extends JPanel implements ItemListener,MouseListener{
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
JSONObject selectedSong = ((JSONObject)value);
SongInfo selectedSong = ((SongInfo)value);
if (isSelected) {
setBackground(list.getSelectionBackground());
@ -133,11 +128,11 @@ public class ReloadSong extends JPanel implements ItemListener,MouseListener{
setBackground(list.getBackground());
setForeground(list.getForeground());
}
setText(selectedSong.getString("english_name")
setText(selectedSong.english_name
+" - "
+((selectedSong.getString("romanized_name").length()>0)?
(!selectedSong.getString("romanized_name").equalsIgnoreCase(selectedSong.getString("name")))?
selectedSong.getString("romanized_name")+"("+selectedSong.getString("name")+")":"":selectedSong.getString("name")));
+((selectedSong.romanized_name.length()>0)?
(!selectedSong.romanized_name.equalsIgnoreCase(selectedSong.name))?
selectedSong.romanized_name+"("+selectedSong.name+")":"":selectedSong.name));
return this;
}
@ -166,7 +161,7 @@ public class ReloadSong extends JPanel implements ItemListener,MouseListener{
}
}
try {
SongData.saveSongToFile(((JSONObject)songs.getSelectedItem()).getString("name"),totalr,totalg,totalb);
SongData.saveSongToFile(((SongInfo)songs.getSelectedItem()).name,totalr,totalg,totalb);
} catch (JSONException | IOException e2) {
e2.printStackTrace();
}

@ -49,7 +49,7 @@ public class SongData {
public static void saveSongToFile(String title, long r, long g, long b) throws IOException {
boolean found=false;
StringBuilder sb = new StringBuilder(title);
StringBuilder sb = new StringBuilder(title.replaceAll(":", "-COLON-"));
sb.append(":");
sb.append(r).append(",")
@ -60,7 +60,7 @@ public class SongData {
String[] split = fileData[i].split(":");
if (split.length>0) {
//System.out.println(split[0]+"/"+title);
if (split[0].equalsIgnoreCase(title)) {
if (split[0].replaceAll("-COLON-", ":").equalsIgnoreCase(title)) {
//System.out.println("Updated color data with new data for "+title+"!");
fileData[i]=sb.toString();
found=true;
@ -88,7 +88,7 @@ public class SongData {
public static SongData ParseSong(String s) {
String[] split = s.split(":");
String title = split[0];
String title = split[0].replaceAll("-COLON-", ":");
String[] data = split[1].split(",");
if (Math.pow(Long.parseLong(data[0]),2)+Math.pow(Long.parseLong(data[1]),2)+Math.pow(Long.parseLong(data[2]),2)<MyRobot.smallestSongColor) {
MyRobot.smallestSongColor=(long)Long.parseLong(data[0])+Long.parseLong(data[1])+Long.parseLong(data[2]);

@ -9,7 +9,6 @@ public class SongInfo {
public String english_name;
public String artist;
public String vocaloid;
public int bpm;
public String album_art;
public JSONObject rating;
public JSONObject notecount;
@ -21,7 +20,6 @@ public class SongInfo {
english_name = jsonData.getString("english_name");
artist = jsonData.getString("artist");
vocaloid = jsonData.getString("vocaloid");
bpm = jsonData.getInt("bpm");
album_art = jsonData.getString("album_art");
rating = jsonData.getJSONObject("rating");
notecount = jsonData.getJSONObject("notecount");

@ -1,431 +0,0 @@
package sig;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.awt.image.WritableRaster;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.imageio.ImageIO;
import sig.utils.FileUtils;
import sig.utils.ImageUtils;
public class TypeFace {
final static int WIDTH = 32;
final static int HEIGHT = 32;
final static int NUMBER_COUNT = 10;
public int blue_minthreshold = 75;
public int green_minthreshold = 0;
public int red_minthreshold = 0;
public int blue_maxthreshold = 255;
public int green_maxthreshold = 150;
public int red_maxthreshold = 126;
public int blue_fillminthreshold = 75;
public int green_fillminthreshold = 0;
public int red_fillminthreshold = 0;
public int blue_fillmaxthreshold = 255;
public int green_fillmaxthreshold = 150;
public int red_fillmaxthreshold = 107;
public boolean darkFillCheck = true;
Color[][] numbers = new Color[WIDTH*HEIGHT][NUMBER_COUNT];
BufferedImage baseImg;
public TypeFace(BufferedImage img) {
this.baseImg = img;
for (int k=0;k<NUMBER_COUNT;k++) {
for (int i=0;i<WIDTH;i++) {
for (int j=0;j<HEIGHT;j++) {
numbers[i*HEIGHT+j][k]=new Color(baseImg.getRGB(i+k*WIDTH, j),true);
}
}
}
}
public int extractNumbersFromImage(BufferedImage img,File saveLoc) {
return extractNumbersFromImage(img,saveLoc,false);
}
public int extractNumbersFromImage(BufferedImage img,File saveLoc,boolean debug) {
final boolean DEBUG_IMG = debug;
for (int x=0;x<img.getWidth();x++) {
for (int y=0;y<img.getHeight();y++) {
Color currentCol = new Color(img.getRGB(x, y));
if (this.equals(DemoApplication.typeface3)) {
if ((currentCol.getRed()>=0 && currentCol.getRed()<=70
&& currentCol.getGreen()>=0 && currentCol.getGreen()<=100
&& currentCol.getBlue()>=0 && currentCol.getBlue()<=120)) {
img.setRGB(x, y, new Color(8,114,140).getRGB());
} else {
img.setRGB(x, y, Color.WHITE.getRGB());
}
} else
if ((currentCol.getRed()>=0 && currentCol.getRed()<=105
&& currentCol.getGreen()>=0 && currentCol.getGreen()<=150
&& currentCol.getBlue()>=0 && currentCol.getBlue()<=150) ||
(this.equals(DemoApplication.typeface2) &&
currentCol.getRed()>=0 && currentCol.getRed()<=120
&& currentCol.getGreen()>=100 && currentCol.getGreen()<=210
&& currentCol.getBlue()>=120 && currentCol.getBlue()<=230
&& currentCol.getGreen()+5<currentCol.getBlue())) {
img.setRGB(x, y, new Color(8,114,140).getRGB());
} else {
img.setRGB(x, y, Color.WHITE.getRGB());
}
}
}
if (!saveLoc.exists()) {
saveLoc.mkdirs();
}
try {
ImageIO.write(img,"png",new File(saveLoc,"img.png"));
} catch (IOException e1) {
e1.printStackTrace();
}
int midY = img.getHeight()/2;
int X = 0;
String extractedNumbers = "";
int state = 0;
BufferedImage numberImg = null;
int iterations=0;
while (X<img.getWidth()) {
boolean success=true;
Color p = new Color(img.getRGB(X, midY),true);
switch (state) {
case 0:{
//Search for a dark pixel.
if (p.getBlue()>blue_minthreshold && p.getBlue()<blue_maxthreshold &&
p.getGreen()>green_minthreshold && p.getGreen()<green_maxthreshold &&
p.getRed()>red_minthreshold && p.getRed()<red_maxthreshold) {
//We found a dark pixel.
state=1;
if (DEBUG_IMG) {
try {
BufferedImage img2 = ImageUtils.toCompatibleImage(ImageUtils.copyBufferedImage(img));
img2.setRGB(X, midY, Color.RED.getRGB());
ImageIO.write(img2,"png",new File("stage1_"+System.currentTimeMillis()+".png"));
} catch (IOException e) {
e.printStackTrace();
}
}
if (darkFillCheck) {
success = fillDark(img,X,midY,0,0,0);
if (!success) {
//We're done.
X=img.getWidth();
break;
}
}
}
}break;
case 1:{
//Move right until light pixel.
//Check if next pixel is also a light pixel.
if (p.getBlue()>200 && p.getGreen()>200 && p.getRed()>200) {
state=2;
if (DEBUG_IMG) {
try {
BufferedImage img2 = ImageUtils.toCompatibleImage(ImageUtils.copyBufferedImage(img));
img2.setRGB(X, midY, Color.RED.getRGB());
ImageIO.write(img2,"png",new File("stage2_"+System.currentTimeMillis()+".png"));
} catch (IOException e) {
e.printStackTrace();
}
}
//System.out.println("Found light pixel");
}
}break;
case 2:{
//Fill algorithm until entire number is filled.
ImgRectangle i = new ImgRectangle();
success = fill(img,X,midY,0,0,i);
if (!success) {
//We're done.
X=img.getWidth();
break;
} else {
numberImg = i.createImage();
if (numberImg.getWidth()>=32) {
state=0;
break;
}
X+=i.maxX;
if (numberImg.getHeight()<10 || numberImg.getWidth()<4) {
//A number should be at least 10 pixels high...This is not satisfactory.
state=4;
break;
}
//X+=numberImg.getWidth();
state=3;
if (DEBUG_IMG) {
try {
BufferedImage img2 = ImageUtils.toCompatibleImage(ImageUtils.copyBufferedImage(img));
img2.setRGB(X, midY, Color.RED.getRGB());
ImageIO.write(img2,"png",new File("stage3_"+System.currentTimeMillis()+".png"));
} catch (IOException e) {
e.printStackTrace();
}
}
//System.out.println("Moving to next step: ");
}
}break;
case 3:{
//Figure out which number in the typeface it best represents.
numberImg = ImageUtils.toCompatibleImage(ImageUtils.toBufferedImage(numberImg.getScaledInstance(WIDTH, HEIGHT, Image.SCALE_FAST)));
//System.out.println(numberImg.getWidth()+"x"+numberImg.getHeight());
int[] hits = new int[NUMBER_COUNT];
double highestRatio = 0;
int highest = 0;
boolean goNext=false;
boolean foundOne=false;
for (int k=0;k<NUMBER_COUNT;k++) {
BufferedImage img2 = ImageUtils.toCompatibleImage(ImageUtils.copyBufferedImage(numberImg));
for (int i=0;i<WIDTH;i++) {
for (int j=0;j<HEIGHT;j++) {
if (i<numberImg.getWidth() &&
j<numberImg.getHeight()) {
Color pixel = new Color(numberImg.getRGB(i, j));
if (numbers[i*HEIGHT+j][k].getRed()==0 && numbers[i*HEIGHT+j][k].getGreen()==255 && numbers[i*HEIGHT+j][k].getBlue()==0
&& pixel.getRed()==255 && pixel.getGreen()==255 && pixel.getBlue()==255) {
goNext=true;
img2.setRGB(i, j, Color.MAGENTA.getRGB());
break;
}
if (numbers[i*HEIGHT+j][k].getRed()==255 && numbers[i*HEIGHT+j][k].getGreen()==0 && numbers[i*HEIGHT+j][k].getBlue()==0
&& pixel.getRed()==0 && pixel.getGreen()==0 && pixel.getBlue()==0) {
goNext=true;
img2.setRGB(i, j, Color.YELLOW.getRGB());
break;
}
if (!goNext) {
foundOne=true;
}
if (numbers[i*HEIGHT+j][k].equals(Color.RED) || numbers[i*HEIGHT+j][k].equals(Color.GREEN) ||
(numbers[i*HEIGHT+j][k].getRed()==pixel.getRed() && numbers[i*HEIGHT+j][k].getGreen()==pixel.getGreen() && numbers[i*HEIGHT+j][k].getBlue()==pixel.getBlue())) {
if (!(numbers[i*HEIGHT+j][k].equals(Color.GREEN) && numbers[i*HEIGHT+j][k].equals(Color.RED))) {
hits[k]++;
}
//System.out.println("Hit for "+((k+1)%NUMBER_COUNT)+"! "+hits[k] + "/"+numbers[i*HEIGHT+j][k]+"/"+pixel);
if ((double)hits[k]/(WIDTH*HEIGHT)>highestRatio) {
highestRatio= (double)(hits[k])/(WIDTH*HEIGHT);
highest=k;
}
} else {
if (pixel.equals(Color.WHITE)) {
img2.setRGB(i, j, Color.BLUE.getRGB());
} else {
img2.setRGB(i, j, Color.RED.getRGB());
}
//FileUtils.logToFile("Pixel difference: "+numbers[i*HEIGHT+j][k]+"/"+pixel, new File(saveLoc,(iterations)+".txt").getPath());
}
}
}
if (goNext) {break;}
}
FileUtils.logToFile(((k+1)%NUMBER_COUNT)+":"+((double)(hits[k])/(WIDTH*HEIGHT)), new File(saveLoc,(iterations)+".txt").getPath());
try {
ImageIO.write(img2,"png",new File(saveLoc,(iterations)+"_"+((k+1)%NUMBER_COUNT)+".png"));
} catch (IOException e) {
e.printStackTrace();
}
goNext=false;
}
if (!foundOne) {
state=0;
iterations++;
break;
}
//System.out.println("Matches closest to "+((highest+1)%NUMBER_COUNT)+" with "+highestRatio);
iterations++;
extractedNumbers+=Integer.toString((highest+1)%NUMBER_COUNT);
state=4;
}break;
case 4:{
//Find light pixels again.
if (p.getBlue()>200 && p.getGreen()>200 && p.getRed()>200) {
X-=2;
state=0;
if (DEBUG_IMG) {
try {
BufferedImage img2 = ImageUtils.toCompatibleImage(ImageUtils.copyBufferedImage(img));
img2.setRGB(X, midY, Color.RED.getRGB());
ImageIO.write(img2,"png",new File("stage4_"+System.currentTimeMillis()+".png"));
} catch (IOException e) {
e.printStackTrace();
}
}
//System.out.println("Found next dark pixel");
}
}break;
}
X++;
}
//System.out.println("Got "+extractedNumbers);
if (extractedNumbers.length()==0) {
return -1;
} else {
return Integer.parseInt(extractedNumbers);
}
}
public boolean fillDark(BufferedImage img,int startX,int startY,int x,int y, int iterations) {
//rect.AddPixel(new Point(x,y), Color.BLACK);
if (iterations>Math.max(img.getWidth(),img.getHeight())) {
return false;
}
img.setRGB(startX+x, startY+y, Color.BLACK.getRGB());
Color p = null;
if (startX+x+1<img.getWidth()) {
p = new Color(img.getRGB(startX+x+1, startY+y));
if (p.getBlue()>blue_fillminthreshold && p.getBlue()<blue_fillmaxthreshold &&
p.getGreen()>green_fillminthreshold && p.getGreen()<green_fillmaxthreshold &&
p.getRed()>red_fillminthreshold && p.getRed()<red_fillmaxthreshold) {
fillDark(img,startX,startY,x+1,y,iterations+1);
}
} else {
return false;
}
if (startX+x-1>0) {
p = new Color(img.getRGB(startX+x-1, startY+y));
if (p.getBlue()>blue_fillminthreshold && p.getBlue()<blue_fillmaxthreshold &&
p.getGreen()>green_fillminthreshold && p.getGreen()<green_fillmaxthreshold &&
p.getRed()>red_fillminthreshold && p.getRed()<red_fillmaxthreshold) {
fillDark(img,startX,startY,x-1,y,iterations+1);
}
} else {
return false;
}
if (startY+y+1<img.getHeight()) {
p = new Color(img.getRGB(startX+x, startY+y+1));
if (p.getBlue()>blue_fillminthreshold && p.getBlue()<blue_fillmaxthreshold &&
p.getGreen()>green_fillminthreshold && p.getGreen()<green_fillmaxthreshold &&
p.getRed()>red_fillminthreshold && p.getRed()<red_fillmaxthreshold) {
fillDark(img,startX,startY,x,y+1,iterations+1);
}
} else {
return false;
}
if (startY+y-1>0) {
p = new Color(img.getRGB(startX+x, startY+y-1));
if (p.getBlue()>blue_fillminthreshold && p.getBlue()<blue_fillmaxthreshold &&
p.getGreen()>green_fillminthreshold && p.getGreen()<green_fillmaxthreshold &&
p.getRed()>red_fillminthreshold && p.getRed()<red_fillmaxthreshold) {
fillDark(img,startX,startY,x,y-1,iterations+1);
}
} else {
return false;
}
return true;
}
public boolean fill(BufferedImage img,int startX,int startY,int x,int y,ImgRectangle rect) {
rect.AddPixel(new Point(x,y), Color.BLACK);
img.setRGB(startX+x, startY+y, Color.BLACK.getRGB());
Color p = null;
if (startX+x+1<img.getWidth()) {
p = new Color(img.getRGB(startX+x+1, startY+y));
if (p.getBlue()>200 && p.getGreen()>200 && p.getRed()>200) {
fill(img,startX,startY,x+1,y,rect);
}
} else {
return false;
}
if (startX+x-1>0) {
p = new Color(img.getRGB(startX+x-1, startY+y));
if (p.getBlue()>200 && p.getGreen()>200 && p.getRed()>200) {
fill(img,startX,startY,x-1,y,rect);
}
} else {
return false;
}
if (startY+y+1<img.getHeight()) {
p = new Color(img.getRGB(startX+x, startY+y+1));
if (p.getBlue()>200 && p.getGreen()>200 && p.getRed()>200) {
fill(img,startX,startY,x,y+1,rect);
}
} else {
return false;
}
if (startY+y-1>0) {
p = new Color(img.getRGB(startX+x, startY+y-1));
if (p.getBlue()>200 && p.getGreen()>200 && p.getRed()>200) {
fill(img,startX,startY,x,y-1,rect);
}
} else {
return false;
}
return true;
}
class ImgRectangle{
int minX=0,maxX=0,minY=0,maxY=0;
List<Pixel> p = new ArrayList<Pixel>();
void AddPixel(Point p, Color c) {
this.p.add(new Pixel(p,c));
if (p.x<minX) {
minX=p.x;
}
if (p.x>maxX) {
maxX=p.x;
}
if (p.y<minY) {
minY=p.y;
}
if (p.y>maxY) {
maxY=p.y;
}
}
BufferedImage createImage() {
int finalWidth = maxX-minX+1;
int offsetX = 0;
int finalHeight = maxY-minY+1;
int offsetY = 0;
/*if (finalWidth > finalHeight) {
//Add padding for height.
offsetY += (finalWidth-finalHeight)/2;
finalHeight+= offsetY*2;
}
if (finalHeight > finalWidth) {
//Add padding for width.
offsetX += (finalHeight-finalWidth)/2;
finalWidth+= offsetX*2;
}*/
BufferedImage bufferedImage = ImageUtils.toCompatibleImage(new BufferedImage(finalWidth, finalHeight,
BufferedImage.TYPE_INT_RGB));
Graphics2D graphics = bufferedImage.createGraphics();
graphics.setPaint ( new Color ( 255, 255, 255 ) );
graphics.fillRect ( 0, 0, bufferedImage.getWidth(), bufferedImage.getHeight() );
for (Pixel pixel : p) {
bufferedImage.setRGB(pixel.p.x-minX+offsetX, pixel.p.y-minY+offsetY, pixel.c.getRGB());
}
return bufferedImage;
}
}
class Pixel{
Point p;
Color c;
Pixel(Point p,Color c) {
this.p=p;
this.c=c;
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 506 KiB

After

Width:  |  Height:  |  Size: 468 KiB

@ -8,7 +8,7 @@ Weekender Girl:9603623129,8143536192,7023009997
神曲:4946258494,4475941595,3340301379
カンタレラ:4503782143,3790000754,2513049117
巨大少女:3731017798,4370780514,7413760542
クローバー♣クラブ:4365468840,5530233610,4779101844
クローバー♣クラブ:5260193720,6627800391,5551285857
恋スルVOC@LOID:11460873603,10480525867,9425227787
桜ノ雨:8300126301,6096391834,6982464695
39:8911910637,8910841892,7738153876
@ -113,7 +113,7 @@ Sweet Devil:6634620218,3136086595,6192411098
テオ:1670938584,1119524410,5147341281
初音ミクの消失 -DEAD END-:6701961288,6767316619,6746417217
秘密警察:3262137487,4000164607,3989724890
妄想スケッチ:5664849812,5303351516,6760495429
妄想スケッチ:6382410753,5949239568,7533122178
リンちゃんなう!:7136782033,6228041551,4262735136
ローリンガール:6764558530,6758136800,6759135862
ロキ:2406990430,945189166,3873292660
@ -162,3 +162,17 @@ Star Story:1808285827,3434600865,4320953611
夢の続き:9980651028,9269054443,7923490029
MEGANE:12097703860,7865703856,8089571528
Change me:6946360046,4571504089,2910280226
アドレサンス:5458033068,4389022230,4212580841
グリーンライツセレナーデ:6422553300,6622495000,6942409156
サウンド:2350288995,3725672868,3350500213
Stay with me:6858394047,5138098343,3976139800
ドラマツルギー:9364452247,9429738184,9396666719
Nyanyanyanyanyanyanya!:8284558575,7067572325,6713348796
巴里映画少女:7543881170,6294797933,6122764603
ファインダー (DSLR remix - re-COLON-edit):5687636652,7373735766,7988148878
フキゲンワルツ:7878892274,8044206152,6207005607
Promise:4021169803,4900248262,6497913358
星屑ユートピア:3370014582,2298015215,925945505
マージナル:7836108651,8174436060,8267809525
Last Night, Good Night:3265412964,4528174454,4889449827
Leia:6765406279,5114086294,4206059909

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.
Loading…
Cancel
Save