Ok, maybe Zoom to Fill could help me...
Printable View
Ok, maybe Zoom to Fill could help me...
Oh, and thanks again Moon Wizard.
If you don't mind helping me understand one more thing...
How come this code moves the image within the window? Based on the descriptions of the functions in the wiki, reading the current viewport and then setting the center with the same values should not move the image in the viewport. But it does. Not always, but certainly with any image that I added to the database records myself (eg. dragging from Assets to Maps list).
Wiki says:Code:local vpX, vpY, vpZoom = image.getViewpoint();
image.setViewpointCenter(vpX, vpY, vpZoom);
andQuote:
getViewpoint
Returns data on the current viewpoint of the user. The viewpoint is determined by the center point of the portion of image being viewed in the control as well as the used zoom level.
Return values
(number)
The X coordinate on the image acting as the center point of the viewpoint(number)
The Y coordinate on the image acting as the center point of the viewpoint(number)
The zoom level being used (a value of 1.0 represents 100% zoom)
In fact, it does work, but only after I execute it once. The first time it executes after opening the image window, it moves. After that, it stays put each time the code runs. It's like it doesn't know where to start, but once I set the center the first time, it has the right coordinates in the database. It really feels like there is something not set right somewhere in memory or the database or something when the image window is first opened.Quote:
setViewpointCenter
Sets the active viewpoint of the user to center on the . The image viewpoint is repositioned so that the given coordinates on the image are centered in the control with the specified zoom level active.
Parameters
viewx (number)
The desired horizontal view point center coordinate
viewy (number)
The desired vertical view point center coordinate
zoom (number) [optional]
The zoom level as a decimal number, with 1.0 being 100% zoom
The current view point is defined as the center point of the view plus the zoom scale. When you call get/set, you are just setting the exact same information back into itself.
Regards,
JPG
I just pre-empted one of the toolbar buttons in the CoreRPG image toolbar with the following code:
function onButtonPress()
local ic = window.getImage();
local vX, vY, vZoom = ic.getViewpoint();
ic.setViewpointCenter(vX, vY, vZoom);
Debug.chat("OLD: ", vX, vY, vZoom);
Debug.chat("NEW: ", ic.getViewpoint());
end
With this code on my maps, I do not see any movement when I press the button.
Example:
s'OLD: ' | #1.58316040039063 | #18.5975341796875 | #0.816916465759277
s'NEW: ' | #1.58316040039063 | #18.5975341796875 | #0.816916465759277
Are you sure that you are not changing the values between the get and set at all?
Regards,
JPG
Well sonofa. For some reason, now it works perfectly. Nothin' moves. I don't get it. I had restarted FGU a number of times while testing, too, and it was still doing it. But it's not now. Cache? Solar flare?