We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › renderers and PGraphics
Page Index Toggle Pages: 1
renderers and PGraphics (Read 980 times)
renderers and PGraphics
May 12th, 2005, 2:32am
 
just out of curiosity ...

how can i use rotateZ() of a PGraphics(-2,-3) object?
the only class that seems to have rotateZ() is PGraphics3 but using that just makes the sketch go blue ... ?

Code:

PImage img;

void setup() {
size(200,200, P3D);
img = loadImage("house.jpg");
}

float rotation = 0.0;

void draw (){
background(0);
image(rotateImage(img, rotation), 0, 0);
rotation += 0.02;
}

PImage rotateImage (PImage _img, float _rad)
{
int xm = _img.width;
int ym = _img.height;

if (_rad == 0) return _img;

PGraphics _bimg = new PGraphics(xm, ym, this);
_bimg.background(255);
_bimg.noStroke();

_bimg.translate(xm/2.0, ym/2.0);

_bimg.rotateZ(_rad); // <------------

_bimg.beginShape(QUADS);
_bimg.texture(img);
_bimg.vertex( -(xm/2), -(ym/2),0, 0,0);
_bimg.vertex( (xm/2), -(ym/2),0, xm,0);
_bimg.vertex( (xm/2), (ym/2),0, xm,ym);
_bimg.vertex( -(xm/2), (ym/2),0, 0,ym);
_bimg.endShape();

return (PImage) _bimg;
}


F
Re: renderers and PGraphics
Reply #1 - May 12th, 2005, 7:05am
 
rotateZ in 2D is the same as rotate(). but making your own PGraphics doesn't work in the current releases.
Page Index Toggle Pages: 1