How to scale/zoom a widget with blueprints?

Perhaps I should’ve included a general overview of how it’s supposed to work so it’s easier to iron out / refactor the bits that are far from perfect.

  • the zooming is based on the number of steps controlled by the mouse wheel
  • Current Zoom Step / Min Zoom / Max Zoom control the zooming process
  • Min of -3 and Max of +3 would produce 5 steps: [-2,-1,0,1,2]
  • Min of -2 and Max of +8 would allow you to zoom out once but zoom in a lot!
  • the Zoom Factor is the magnitude of a step where 0.4 = 60% or 0.9 =10% of the current widget scale (kind of)
  • it’s ‘kind of’ because of how scaling works, in order to be consistent both ways and account for the current scale, we need to use the inverse of 1 here; otherwise we will not return to where we started
  • if you zoom in by 20%, you’re at 1.20 scale but if you zoom out of that 1.20 by 20%… that’s actually 24% of the scale instead since we’re using a greater base
  • also, the Zoom Factorshould not exceed 1 or it would reverse the process. Low values, below 0.5% should be, ideally, avoided as it might look too jarring (unless we work in interpolation). But should still work OK and might be even necessary for huge maps - like a star map!

As for the whole process: we scale the image up and down and shift it in such a way, that the pixel under the cursor remains in the same position after the Scale & Translate have taken place. As demonstrated by the navy-blue spaghetti. :expressionless:

4 Likes