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 & HelpSyntax Questions › ImageMode(CENTER)???
Page Index Toggle Pages: 1
ImageMode(CENTER)??????? (Read 655 times)
ImageMode(CENTER)???????
Dec 19th, 2006, 10:24pm
 
Hey everybody. I am trying to build the following code in processing. I am trying basically to zoom in, by clicking the mouse button, into 4 png's from the CENTER of them. I can't do it since the imageMode works only with the CORNERS or CORNER of the image. I am also attaching my code.Thanks in advance


CODE:

PImage a;
PImage b;
PImage c;
PImage d;
int m=0;
int n=0;

void setup() {
 size(640,480);
 a = loadImage("1.png");
 b = loadImage("2.png");
 c = loadImage("3.png");
 d = loadImage("4.png");
}

void draw() {
 background(255);
 imageMode(CORNERS);
 image(a, m/4,n/4);
 image(b, m/3, n/3);
 image(c, m/2, n/2);
 image(d, m, n);
}

void mousePressed() {
 m+=10;
 n+=10;
 redraw();
}
Re: ImageMode(CENTER)???????
Reply #1 - Dec 20th, 2006, 8:09am
 
Well I can't entirely understand what you want, in your code right now it doesn't matter what the imageMode is, since you never scale them in any way. The image method when called with 3 parameters just draws the image unscaled at that location.

If what you want is four PNGs drawn thus:
Code:

_______
| | |
| a | b |
|___|___|
| | |
| c | d |
|___|___|


and clicking zooms in towards the center, then what you COULD do is,

Code:

PImage a;
PImage b;
PImage c;
PImage d;
int scaleBy = 1;
// This assumes the images have the same width and height,
// and that this is the actual size of the images you want
// to draw.
int imgwidth = 10, imgheight =10;

void setup() {
size(640,480);
a = loadImage("1.png");
b = loadImage("2.png");
c = loadImage("3.png");
d = loadImage("4.png");
}

void draw() {
background(255);
translate(width/2,height/2);
scale(scaleBy);
image(a,-imgWidth, -imgHeight);
image(b,0,-imgHeight);
image(c,-imgWidth,0);
image(d,0,0);
}

void mousePressed() {
scale += 0.1;
}


Although if I've misunderstood what you're trying to do then this will be totally useless.
Re: ImageMode(CENTER)???????
Reply #2 - Dec 26th, 2006, 8:54pm
 
Hey!Thanks for the quick reply!Well the pngs are not exactly as u drew them so below i have a rough sketch...
And to be more specific what my project is about is to have a projector showing these pngs which they are going to be a perpective theatre. When someone steps in front of the projector the colour of his cast shadow will be tracked by JMyron and it will start to zoom in. When the first png starts to zoom in it will zoom till the edge of the screen and it will be lost the second will continue zooming in and will be lost at the edge of the screen and so on.

|-----------1-----------|
||----------2----------||
|||---------3---------|||
||||--------4--------||||
||||                 ||||
||||                 ||||
||||                 ||||
||||                 ||||
||||                 ||||
||||                 ||||

Unforunately when i preview my sketch above it is a bit misleading but try to imagine that all the right side vertical lines are one below the other and no scattered in the middle of the sketch.

I also include the code u sent me.

CODE:
PImage a;  
PImage b;  
PImage c;  
PImage d;  
int scaleBy = 1;  
// This assumes the images have the same width and height,  
// and that this is the actual size of the images you want  
// to draw.  
int imgWidth = 10, imgHeight =10;  
 
void setup() {  
 size(640,480);  
 a = loadImage("1.png");  
 b = loadImage("2.png");  
 c = loadImage("3.png");  
 d = loadImage("4.png");  
}  
 
void draw() {  
 background(255);  
 translate(width/2,height/2);  
 scale(scaleBy);  
 image(a,-imgWidth, -imgHeight);  
 image(b,0,-imgHeight);  
 image(c,-imgWidth,0);  
 image(d,0,0);  
}  
 
void mousePressed() {  
 scaleBy += 0.1;  
}

Thanks very much!
Page Index Toggle Pages: 1