Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17560

Zoom to mouse cursor and get mouse location on zoomed image

$
0
0

Hi guys

I have a image tool I am working on. I zoom to the mouse location using the following code:

float x = float(imgrender.mx - imgrender.bgx);

  float y = float(imgrender.my - imgrender.bgy);

  float pscale = imgrender.bgscale;

  imgrender.bgscale = max(min(imgrender.bgscale + (zDelta > 0 ? 0.1f : -0.1f), 100.0f), 0.20f);

  float newx = x * (imgrender.bgscale / pscale);

  float newy = y * (imgrender.bgscale / pscale);

  imgrender.bgx += (x - newx);

  imgrender.bgy += (y - newy);

I then take the bgx/bgy values, and set them to my viewport Topleft X/Y coordinates …


Viewing all articles
Browse latest Browse all 17560

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>