-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlimitFinder.pde
More file actions
57 lines (53 loc) · 1.5 KB
/
limitFinder.pde
File metadata and controls
57 lines (53 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.FileOutputStream;
PImage bg;
int c;
int[][] mainMatrix = new int[168][71];
String fileName = "limitsMatrix";
File file = new File(fileName);
PrintWriter outputStream = null;
void setup(){
bg = loadImage("mapbw.png");
//check all x's
for(int n = 0; n<168; n++){
//check all y's
for(int m = 0; m<71; m++){
//check all x pixels of the square
for(int i = 0; i< 30; i++){
//check all y pixels of the square
for(int j = 0; j<30; j++){
c = bg.get(n*30+i, m*30+j);
//if the square has a pixel from the input color then
//the square is marked
if(c == -16777216){
mainMatrix[n][m] = 1;
}
c= 0;
}
}
}
}
try{
if (!file.exists()){
outputStream = new PrintWriter(fileName);
} else {
outputStream = new PrintWriter(new FileOutputStream(fileName, true));
}
if (file.canWrite() == true){
for(int l = 0; l<168; l++){
for(int k = 0; k<71; k++){
outputStream.println(mainMatrix[l][k]);
}
}
} else {
}
}
catch(Exception e){
System.out.println("Error opening or creating file" + fileName);
}
outputStream.close();
}