getViewArea: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(getViewArea return format and parameter use was broken) |
||
Line 3: | Line 3: | ||
|version=1.5.0 | |version=1.5.0 | ||
|description= | |description= | ||
Returns the limits of the visible area of the map window, given in either pixels or cell coordinates depending on the first parameter. | Returns the limits of the visible area of the map window, given in either pixels or cell coordinates depending on the first parameter. The result is in a ";" delimited String as default or can be configured by setting the delimiter or using Json. | ||
|usage= | |usage= | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
getViewArea() | |||
getViewArea(pixels) | getViewArea(pixels) | ||
getViewArea(pixels, delim) | |||
</source> | </source> | ||
'''Parameters''' | '''Parameters''' | ||
* {{code|pixels}} - if set to true (1) means the returned coordinates are measured in pixels. If set to false (0) the returned coordinates are measured in map cells. Defaults to {{code|true}}. | * {{code|pixels}} - if set to true (1) means the returned coordinates are measured in pixels. If set to false (0) the returned coordinates are measured in map cells. Defaults to {{code|true}}. | ||
* {{code|delim}} - if set to "json" means the returned coordinates are defined in JSON style. Otherwise a String property list is returning using delim as a delimiter. If set to false (0) the returned coordinates are measured in map cells. Defaults to {{code|;}}. | |||
|examples= | |examples= | ||
Get the viewport dimensions of the current client | Get the viewport dimensions of the current client: | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[ | Default pixels: [r: getViewArea()] | ||
</source> | Cells: [r: getViewArea(0)] | ||
Pixels: [r: getViewArea(1)] | |||
Cells as JSON: [r: getViewArea(0, "json")] | |||
Pixels as JSON: [r: getViewArea(1, "json")] | |||
Cells as "," separated String properties: [r: getViewArea(0, ",")] | |||
Pixels as ";" separated String properties: [r: getViewArea(1, ";")]</source> | |||
Results to: | |||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
Default pixels: offsetX=0; offsetY=0; width=886; height=616 | |||
Cells: offsetX=0; offsetY=0; width=17; height=12 | |||
Pixels: offsetX=0; offsetY=0; width=886; height=616 | |||
Cells as JSON: {"offsetX":0,"offsetY":0,"width":886,"height":616} | |||
Pixels as JSON: {"offsetX":0,"offsetY":0,"width":886,"height":616} | |||
Cells as "," separated String properties: offsetX=0, offsetY=0, width=886, height=616 | |||
Pixels as ";" separated String properties: offsetX=0; offsetY=0; width=886; height=616 | |||
</source> | </source> | ||
|also= | |also= | ||
{{func|setViewArea}}, {{func|goto}}, {{func|setZoom}}, {{func|getZoom}}. | {{func|setViewArea}}, {{func|goto}}, {{func|setZoom}}, {{func|getZoom}}. | ||
|change= | |||
{{change|1.5.1|fix the output of the function as it was incorrectly formatted, now the pixels parameter correctly defaults to true, you can use a delimiter to define output format}} | |||
}} | }} | ||
[[Category:Miscellaneous Function]] | [[Category:Miscellaneous Function]] |
Revision as of 14:24, 17 March 2019
getViewArea() Function
• Introduced in version 1.5.0
Returns the limits of the visible area of the map window, given in either pixels or cell coordinates depending on the first parameter. The result is in a ";" delimited String as default or can be configured by setting the delimiter or using Json.
Usage
getViewArea()
getViewArea(pixels)
getViewArea(pixels, delim)
Parameters
pixels
- if set to true (1) means the returned coordinates are measured in pixels. If set to false (0) the returned coordinates are measured in map cells. Defaults totrue
.delim
- if set to "json" means the returned coordinates are defined in JSON style. Otherwise a String property list is returning using delim as a delimiter. If set to false (0) the returned coordinates are measured in map cells. Defaults to;
.
Examples
Get the viewport dimensions of the current client:
Default pixels: [r: getViewArea()]
Cells: [r: getViewArea(0)]
Pixels: [r: getViewArea(1)]
Cells as JSON: [r: getViewArea(0, "json")]
Pixels as JSON: [r: getViewArea(1, "json")]
Cells as "," separated String properties: [r: getViewArea(0, ",")]
Pixels as ";" separated String properties: [r: getViewArea(1, ";")]
Results to:
Default pixels: offsetX=0; offsetY=0; width=886; height=616
Cells: offsetX=0; offsetY=0; width=17; height=12
Pixels: offsetX=0; offsetY=0; width=886; height=616
Cells as JSON: {"offsetX":0,"offsetY":0,"width":886,"height":616}
Pixels as JSON: {"offsetX":0,"offsetY":0,"width":886,"height":616}
Cells as "," separated String properties: offsetX=0, offsetY=0, width=886, height=616
Pixels as ";" separated String properties: offsetX=0; offsetY=0; width=886; height=616