FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Programs
(Moderators: fry, REAS)
   typography problem
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: typography problem  (Read 408 times)
benelek

35160983516098 WWW Email
typography problem
« on: Feb 22nd, 2003, 1:11pm »

 sorry about sticking the task of debugging to the board... but i can't for the life of me figure out why the following code doesn't work the way i'm intending.
 
  it's basically the same as the noise1 example i posted a couple of days ago in the "nonresponsive" section, but i've changed the image and added a screenGrab function.
 
  the problem is that only the first screengrab imprints a timestamp on the image, though i can't figure out why it doesn't for the rest.
 
Code:

void setup() {
  size(352,288);
  noBackground();
  backImg = loadImage("In da office.JPG");
  timeLog = loadFont("BauerBodoni-Bold.vlw.gz");
  setFont(timeLog);
  System.arraycopy(backImg.pixels,0,pixels,0,backImg.pixels.length);
}
 
BImage backImg;
BFont timeLog;
boolean scrnSht=false;
 
void loop() {
  int addOn=0;
   
  //horizontal run.
  for(int i=0; i<pixels.length; i++) {
    if(i%width == 0) {
 addOn = int(random(0,10));
    }
    pixels[i]+=addOn;
  }
   
  //vertical run.
  for(int i=0; i<width; i++) {
    for(int j=0; j<pixels.length; j+=width) {
 if(j==0) {
   addOn = int(random(-30,0));
 }
 pixels[i+j]+=addOn;
    }
  }
   
  //screengrab part.
  if(scrnSht==true) {
    int ellapsed = millis()/3600000;
    int[] pixelsA = new int[pixels.length];
    System.arraycopy(pixels,0,pixelsA,0,pixels.length);
 scale(2);
 text(ellapsed + " hrs",5,7);
 scale(0.5);
    screenGrab();
    pixels = pixelsA;
    scrnSht=false;
  }
}
 
void keyPressed() {
  if(key==' ') { scrnSht=true; }
}

 
thanks,
 
-jacob
 
fry


WWW
Re: typography problem
« Reply #1 on: Feb 22nd, 2003, 4:06pm »

i don't see anything immediate, it's a longshot, but it might be a threading issue.. i wonder if somehow screenGrab() hasn't finished writing data before you switch back pixels and pixelsA on that very next line, and so it's writing the non-timestamped image.  
 
you might try setting a single pixel in the other pixels array to red or something obvious and see if that's what's going on.
 
fyi, you can also use setFont(timeLog, 24) instead doing that extra scale() before you draw the text.
 
benelek

35160983516098 WWW Email
Re: typography problem
« Reply #2 on: Feb 23rd, 2003, 7:11am »

mm, well i'm not sure what difference this makes, but when i changed "pixels = pixelsA;" into an arraycopy, the problem was fixed. could the problem still be in threading?
 
Pages: 1 

« Previous topic | Next topic »