Loading...
Logo
Processing Forum
 
hi forum
 
the following example is using a pgraphics to reproduce the screen drawing in a larger resolution (sphere in the middle of the screen).
 
since I've updated to processing 2.0.2 my code behaves completely different. so maybe i'm doing something fundamentally wrong or there's a glitch in 2.0.2. can someone look into the following example and let me know if it's me or processing that's doing it wrong?
 
to reproduce:
1. start the sketch
2. hit any key to dump the pgraphics into a tif-file
3. expected result: screen: sphere in the center / file: sphere in the center
4. result: screen: sphere is totally offset / file: sphere in the center
 
 
 

//toggle hires-pgraphics
boolean makehires = true;
int myWidth = 300;
int myHeight = 300;
int hires_scale = 3;
int myWidth_hires = myWidth * hires_scale;
int myHeight_hires = myHeight * hires_scale;
PGraphics hires;

////////////////////////////////////////////////////////////////////////////////
void setup() {
  // setup screen
  size(myWidth, myHeight, P3D);
  if (makehires){
    hires = createGraphics(myWidth_hires, myHeight_hires, P3D);
  }
}

void draw() {
  // drawing a sphere ono the screen
  background(0);
  stroke(0);
  fill(255);
  camera(width/2.0, height/2.0, (height/2.0) / tan(PI*30.0 / 180.0), width/2.0, height/2.0, 0, 0, 1, 0);
  translate(width/2, height/2, 0);
  sphere(100);
  // replicating the same sphere scaled in hires
  if (makehires){
    hires.beginDraw();
    hires.background(0);
    hires.stroke(0);
    hires.fill(255);
    hires.camera(hires.width/2.0, hires.height/2.0, (hires.height/2.0) / tan(PI*30.0 / 180.0), hires.width/2.0, hires.height/2.0, 0, 0, 1, 0);
    hires.translate(hires.width/2, hires.height/2, 0);
    hires.sphere(100);
    hires.endDraw();
  }
}

void keyReleased() {
  if (makehires){
    String timestamp = year() + nf(month(),2) + nf(day(),2) + "-"  + nf(hour(),2) + nf(minute(),2) + nf(second(),2); 
    hires.save(timestamp + ".tif"); // Saves a TIFF file named xxxx.tif
  }
}
 
 
 
 
 

Replies(4)

It's worked for me after modifying size() to be bigger:
size(myWidth_hires, myHeight_hires, P3D);
yes, if both sizes are the same, all is good. but that's exactly not what it should be in the given case.
HI, as far as I can tell, this is due to a bug in 2.0.2, however it has already been fixed by now in the Processing repo. The next release will incorporate the fix.
hi andres.
thanks for confirming. that's what I suspected.
I updated from 2.0.1 to 2.0.2 because of the memory issues and now have that new problem. but I have to finish the project this week. where can I get a compiled version for win/64? from the repo?