So there I was, hacking away at the keyboard, trying to make magic happen on-screen. Every approach I tried for panning gave incredibly strange results, often causing the image to fly off-screen as soon as I moved the mouse. My Slipslide 2 menu / ShinyPic grid view formula simply didn't want to work in this particular situation.
Irritated, I decided to slam out a quick death-or-glory mess to see what would happen. Well, it started fairly neat and orderly, but as I typed I kept thinking of random things to put in, and so the line got longer and longer and ended up with at least ten nested layers of brackets. Sniggering, I did a quick test run to see how buggered it would be.
And guess what? The code ran perfectly, and the panning was smooth and precise. It is at times like these where my usual response, "Oh shit", simply doesn't cover the magnitude of the situation. After a few seconds of pondering what to do instead, I opted for a more obscene word. Sadly, this was to no avail as pronunciation becomes somewhat impossible when your jaw is lost somewhere on the floor behind the computer-related spaghetti heap.
I have to say, this speaks volumes of my subconscious' programming skills. I never could have done it,anyway. Behold the majestic solution proposed by an unknown entity hiding somewhere within the back of my mind:
mouseoffsetx = ((float(self.screen.get_width()) / 2.0) - float(mousepos))
centrex = (float(self.screen.get_width()) / 2.0) + (mouseoffsetx * ( ((float(self.scaledimage.get_width()) - float(self.screen.get_width()) ) / 2.0) / (float(self.screen.get_width() / 2.0) ) ))
mouseoffsety = ((float(self.screen.get_height()) / 2.0) - float(mousepos))
centrey = (float(self.screen.get_height()) / 2.0) + (mouseoffsety * ( ((float(self.scaledimage.get_height()) - float(self.screen.get_height()) ) / 2.0) / (float(self.screen.get_height() / 2.0) ) ))
Ridiculous, no? Well, now I have to try and work out why that stuff works. If I'm not back in five months' time, send in a search party.