ZipD wrote:Thank you for the code. However, it doesn't zoom into the position of the mouse, all it does it zoom in, which I've already accomplished earlier. In your code, if you zoom into somewhere near the edges, the entire image gets displaced and no longer retain the specified #Width# and #Height# as defined in variables.
Well, I think my last code zooms exactly where the mouse is when you zoom. If this point is too close to any of the edges of the skin, the zoomed meter will be partially transparent, being uncovered by the image. But if you zoom somewhere farther of the edges, it zooms exactly into the position of the mouse. Doesn't it?
ZipD wrote:But I think you may be closer to the solution than me, can you explain this line and what does it do?
Code: Select all
[!SetOption MeterMapImage ImageCrop "(#ImageWidth#*$MouseX:%$/100-#Width#/2),(#ImageHeight#*$MouseY:%$/100-#Height#/2),#Width#,#Height#"]
I know what ImageCrop does but please explain the formula itself?
When you scroll up, the MouseScrollUpAction option of the [MeterMapImage] meter cut out the image (being applied). The cropping is done from the point with the
(#ImageWidth#*$MouseX:%$/100-#Width#/2) and
(#ImageHeight#*$MouseY:%$/100-#Height#/2) coordinates. For the X coordinate for example
$MouseX:%$/100 is the percentage of the width of image where you scrolled (
$MouseX:%$ being a number between 0 and 100, it must be divided by 100, to get a subunit number - which in fact is the mathematically expressed percentage). This must be multiplied by the width of the image, to get the horizontal coordinate of the point where you scrolled. Finally from this calculation we've extracted half of the width of the meter. If this last extraction wouldn't be done, the mouse position wouldn't be in the center of the zoomed surface, but in its upper left corner. Same for the vertical coordinate.
The size of the cropped surface is
#Width# and
#Height# (last two parameters of the option).
Sorry if all this isn't clear enough, my not too good English doesn't let me to explain it better, but I hope you understood.