Bug 1219 : sketch screen is not updated unless dragged 'beneath' the monitor screen
Last modified: 2009-03-26 07:06




Status:
RESOLVED
Resolution:
INVALID -
Priority:
P2
Severity:
normal

 

Reporter:
MaltaCross
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2009-03-26 03:57
I am having a very strange problem with the code that I have written. The code
compiles and run, but acts strangely, as I will explain.

The code first draws a grid on a grey background. This part is OK.

Then, following a mouse click, the code is supposed to insert two icons (a heart and
a spade) at determined positions on the grid.

However, when the mouse is clicked, nothing appears. BUT if the sketch window is
dragged down (i.e. under the monitor screen), and then dragged up again, well the
icons appear! What on earth is happening here?

All assistance would be most welcome. Here is my code :


void setup() {
size(700, 500, P3D);

background (210) ;
frameRate(12);


int Cell = 50 ;

// vertical lines - grid
for (int xCounter=0 ; xCounter < width ; xCounter = xCounter + Cell ) {
stroke (200) ; strokeWeight (1) ;
line (xCounter, 0, xCounter, height) ;
}

// horizontal lines - grid
for (int yCounter=0 ; yCounter < height ; yCounter = yCounter + Cell ) {
stroke (200) ; strokeWeight (1) ;
line (0, yCounter, width, yCounter) ;
}

} // end of setup()



int columns = 14 ; // column - position x
int rows = 10 ; // row - position y

int [][] suit = new int [columns+1][rows+1] ; // [width/Cell] [height/Cell]
int [][] direction = new int [columns+1][rows+1] ; // [width/Cell] [height/Cell]


int Cell = 50 ;


void draw() {
}





void mousePressed() {


columns = 14 ; // column - position x
rows = 10 ; // row - position y

initial() ; // initial conditions




// Rule01 (xScreen/Cell, yScreen/Cell) ;
// paint() ;
// patch(6,4) ;


} // end of MousePressed() loop




void patch(int x,int y) { // maps decorative patch
stroke (200) ; strokeWeight (0) ;

PImage a = loadImage("heart.tif");

switch(suit[x][y]) {
case 1:
a = loadImage("heart.tif");
break;
case 2:
a = loadImage("diamond.tif");
break;
case 3:
a = loadImage("clubs.tif");
break;
case 4:
a = loadImage("spades.tif");
break;
default:
println("the suit is over 4!!"); // Does not execute
break;
}


textureMode(NORMALIZED);
beginShape(); // near panel
texture(a);
vertex (Cell*(x), Cell*(y-1), 1,0);
vertex (Cell*(x), Cell*y, 1,1);
vertex (Cell*(x-1), Cell*y, 0,1);
vertex (Cell*(x-1),Cell*(y-1), 0, 0);
endShape (CLOSE) ;
}



void paint() {

for (int yScreen=1 ; yScreen <= rows ; yScreen++ ) { // runs through the rows
for (int xScreen=1 ; xScreen <= columns ; xScreen++ ) { // runs through
the columns

if (suit [xScreen] [yScreen] > 0) {

patch (xScreen, yScreen) ;
}
}
}
}



void initial() {
suit [6][4] = 1 ;
suit [8][9] = 4 ;
}
Additional Comment #1 From fry 2009-03-26 06:50
paint() is a function used by processing; by writing a method named paint()
you've disabled it. rename your paint() function to something else.
Additional Comment #2 From MaltaCross 2009-03-26 07:06
Thanks Mr.Fry. You are right. I followed your advice and the code worked.

May I ask if there is a complete list of the functions used by Processing?
Paint() does not seem to be in the 'Reference' list!

Anyway, thanks again.

PS. (looking forward to the resolution of bug 1212! :-)