My calculations seem to be moving the image around more than scaling it. Not quite sure where I'm going wrong. I thought I followed the other post on here correctly but it's not quite right.
int xPos = ev.xbutton.x;
int yPos = ev.xbutton.y;
double xCenter = (double) ((double) ((double) xPos / X_RESN) * (rmax - rmin)) + rmin;
double yCenter = (double) ((double) ((double) yPos / Y_RESN) * (imax - imin)) + imin;
double pixelFactors[4];
if(ev.xbutton.button == 1) //Left click, zoom in
{
rmin = (double) xCenter + (rmin + 0.3);
rmax = (double) xCenter + (rmax - 0.3);
imin = (double) yCenter + (imin + 0.3);
imax = (double) yCenter + (imax - 0.3);
}
else if(ev.xbutton.button == 3) //Right click, zoom out
{
rmin = -2;
rmax = 2;
imin = -2;
imax = 2;
}
xPos
andyPos
involved? – luser droog