ok... the rectangle works fine...but what I want to do is a little more complex...
In every rectangle there should be a little drawing of connecting points...
But with this translate() every little drawing is layered on each other and copied in every square...
this is the code I have so far (please don't laugh :) I'm trying ):
data in numbers.txt:
4 9 7 1 5 3 6 2 8
2 1 3 8 9 6 4 5 7
8 6 5 4 2 7 3 9 1
7 4 9 2 6 1 3 8 5
5 6 8 3 7 4 1 2 9
2 1 3 9 5 8 7 4 6
5 3 6 9 7 2 8 1 4
7 4 2 6 8 1 9 3 5
1 8 9 5 3 4 6 7 2
code:
Cell[] cells;
int sudCell = 1;
void setup() {
size(121, 121);
cells = new Cell[1] ;
for(int i = 0; i < sudCell; i++) {
for(int j = 0; j < sudCell; j++) {
cells[i] = new Cell(i , j , 40, 40);
noLoop();
}
}
}
void draw() {
background(255);
for (int i = 0; i < sudCell; i++) {
cells[i] .display();
}
}
class Cell {
int x,y;
int w,h;
int[] a = new int[9];
int[] b = new int[9];
int[] xgrid = { 10, 20, 30};
int[] ygrid = { 10, 20, 30};
Cell(int x_, int y_, int w_, int h_) {
x = x_;
y = y_;
w = w_;
h = h_;
}
void display() {
String[] numbers = loadStrings("numbers.txt");
println(numbers );
for (int i = 0; i < numbers.length; i++) {
int[] nr = int(split(numbers[i], ' '));
if (nr [0] == 1) { a[0] = 10; b[0] = 10; }
if (nr [0] == 2) { a[0] = 20; b[0] = 10; }
if (nr [0] == 3) { a[0] = 30; b[0] = 10; }
if (nr [0] == 4) { a[0] = 10; b[0] = 20; }
if (nr [0] == 5) { a[0] = 20; b[0] = 20; }
if (nr [0] == 6) { a[0] = 30; b[0] = 20; }
if (nr [0] == 7) { a[0] = 10; b[0] = 30; }
if (nr [0] == 8) { a[0] = 20; b[0] = 30; }
if (nr [0] == 9) { a[0] = 30; b[0] = 30; }
if (nr [1] == 1) { a[1] = 10; b[1] = 10; }
if (nr [1] == 2) { a[1] = 20; b[1] = 10; }
if (nr [1] == 3) { a[1] = 30; b[1] = 10; }
if (nr [1] == 4) { a[1] = 10; b[1] = 20; }
if (nr [1] == 5) { a[1] = 20; b[1] = 20; }
if (nr [1] == 6) { a[1] = 30; b[1] = 20; }
if (nr [1] == 7) { a[1] = 10; b[1] = 30; }
if (nr [1] == 8) { a[1] = 20; b[1] = 30; }
if (nr [1] == 9) { a[1] = 30; b[1] = 30; }
if (nr [2] == 1) { a[2] = 10; b[2] = 10; }
if (nr [2] == 2) { a[2] = 20; b[2] = 10; }
if (nr [2] == 3) { a[2] = 30; b[2] = 10; }
if (nr [2] == 4) { a[2] = 10; b[2] = 20; }
if (nr [2] == 5) { a[2] = 20; b[2] = 20; }
if (nr [2] == 6) { a[2] = 30; b[2] = 20; }
if (nr [2] == 7) { a[2] = 10; b[2] = 30; }
if (nr [2] == 8) { a[2] = 20; b[2] = 30; }
if (nr [2] == 9) { a[2] = 30; b[2] = 30; }
if (nr [3] == 1) { a[3] = 10; b[3] = 10; }
if (nr [3] == 2) { a[3] = 20; b[3] = 10; }
if (nr [3] == 3) { a[3] = 30; b[3] = 10; }
if (nr [3] == 4) { a[3] = 10; b[3] = 20; }
if (nr [3] == 5) { a[3] = 20; b[3] = 20; }
if (nr [3] == 6) { a[3] = 30; b[3] = 20; }
if (nr [3] == 7) { a[3] = 10; b[3] = 30; }
if (nr [3] == 8) { a[3] = 20; b[3] = 30; }
if (nr [3] == 9) { a[3] = 30; b[3] = 30; }
if (nr [4] == 1) { a[4] = 10; b[4] = 10; }
if (nr [4] == 2) { a[4] = 20; b[4] = 10; }
if (nr [4] == 3) { a[4] = 30; b[4] = 10; }
if (nr [4] == 4) { a[4] = 10; b[4] = 20; }
if (nr [4] == 5) { a[4] = 20; b[4] = 20; }
if (nr [4] == 6) { a[4] = 30; b[4] = 20; }
if (nr [4] == 7) { a[4] = 10; b[4] = 30; }
if (nr [4] == 8) { a[4] = 20; b[4] = 30; }
if (nr [4] == 9) { a[4] = 30; b[4] = 30; }
if (nr [5] == 1) { a[5] = 10; b[5] = 10; }
if (nr [5] == 2) { a[5] = 20; b[5] = 10; }
if (nr [5] == 3) { a[5] = 30; b[5] = 10; }
if (nr [5] == 4) { a[5] = 10; b[5] = 20; }
if (nr [5] == 5) { a[5] = 20; b[5] = 20; }
if (nr [5] == 6) { a[5] = 30; b[5] = 20; }
if (nr [5] == 7) { a[5] = 10; b[5] = 30; }
if (nr [5] == 8) { a[5] = 20; b[5] = 30; }
if (nr [5] == 9) { a[5] = 30; b[5] = 30; }
if (nr [6] == 1) { a[6] = 10; b[6] = 10; }
if (nr [6] == 2) { a[6] = 20; b[6] = 10; }
if (nr [6] == 3) { a[6] = 30; b[6] = 10; }
if (nr [6] == 4) { a[6] = 10; b[6] = 20; }
if (nr [6] == 5) { a[6] = 20; b[6] = 20; }
if (nr [6] == 6) { a[6] = 30; b[6] = 20; }
if (nr [6] == 7) { a[6] = 10; b[6] = 30; }
if (nr [6] == 8) { a[6] = 20; b[6] = 30; }
if (nr [6] == 9) { a[6] = 30; b[6] = 30; }
if (nr [7] == 1) { a[7] = 10; b[7] = 10; }
if (nr [7] == 2) { a[7] = 20; b[7] = 10; }
if (nr [7] == 3) { a[7] = 30; b[7] = 10; }
if (nr [7] == 4) { a[7] = 10; b[7] = 20; }
if (nr [7] == 5) { a[7] = 20; b[7] = 20; }
if (nr [7] == 6) { a[7] = 30; b[7] = 20; }
if (nr [7] == 7) { a[7] = 10; b[7] = 30; }
if (nr [7] == 8) { a[7] = 20; b[7] = 30; }
if (nr [7] == 9) { a[7] = 30; b[7] = 30; }
if (nr [8] == 1) { a[8] = 10; b[8] = 10; }
if (nr [8] == 2) { a[8] = 20; b[8] = 10; }
if (nr [8] == 3) { a[8] = 30; b[8] = 10; }
if (nr [8] == 4) { a[8] = 10; b[8] = 20; }
if (nr [8] == 5) { a[8] = 20; b[8] = 20; }
if (nr [8] == 6) { a[8] = 30; b[8] = 20; }
if (nr [8] == 7) { a[8] = 10; b[8] = 30; }
if (nr [8] == 8) { a[8] = 20; b[8] = 30; }
if (nr [8] == 9) { a[8] = 30; b[8] = 30; }
stroke(0);
noFill();
rect(x,y,w,h);
for(int m = 0; m < width; m+=40) {
for ( int n = 0; n < height; n+=40) {
pushMatrix();
translate(m, n);
rect(x, y, w, h);
line ( xgrid[0], ygrid[0], a[0], b[0] );
line ( xgrid[1], ygrid[0], a[1], b[1] );
line ( xgrid[2], ygrid[0], a[2], b[2] );
line ( xgrid[0], ygrid[1], a[3], b[3] );
line ( xgrid[1], ygrid[1], a[4], b[4] );
line ( xgrid[2], ygrid[1], a[5], b[5] );
line ( xgrid[0], ygrid[2], a[6], b[6] );
line ( xgrid[1], ygrid[2], a[7], b[7] );
line ( xgrid[2], ygrid[2], a[8], b[8] );
popMatrix();
}
}
}
}}
really hope you can help! I really want to finish this !
Thanx!!!!