getViewArea: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (Text replacement - "<source" to "<syntaxhighlight") |
||
(12 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{MacroFunction | {{MacroFunction | ||
|name= getViewArea | |name= getViewArea | ||
|version= | |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 map 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= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
getViewArea() | |||
getViewArea(pixels) | getViewArea(pixels) | ||
</ | getViewArea(pixels, delim) | ||
</syntaxhighlight> | |||
'''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. | * {{code|pixels}} - if set to true (1) means the returned coordinates are measured in map 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 {{code|delim}} as a delimiter. Defaults to {{code|;}}. | |||
|examples= | |examples= | ||
Get the viewport dimensions of the current client | Get the viewport dimensions of the current client: | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[ | [r: getViewArea()] <!-- Default pixels --> | ||
</ | [r: getViewArea(0)] <!-- in Grid Cells --> | ||
[r: getViewArea(1)] <!-- in Pixels --> | |||
[r: getViewArea(0, "json")] <!-- Cells as JSON --> | |||
[r: getViewArea(1, "json")] <!-- Pixels as JSON --> | |||
[r: getViewArea(0, ",")] <!-- Cells as "," separated String properties: --> | |||
[r: getViewArea(1, ";")] <!-- Pixels as ";" separated String properties: --> | |||
</syntaxhighlight> | |||
Output: | |||
< | <syntaxhighlight lang="mtmacro" line> | ||
startX=0; startY=0; endX=886; endY=616 | |||
</ | startX=0; startY=0; endX=17; endY=12 | ||
startX=0; startY=0; endX=886; endY=616 | |||
{"startX":0,"startY":0,"endX":886,"endY":616} | |||
{"startX":0,"startY":0,"endX":886,"endY":616} | |||
startX=0, startY=0, endX=886, endY=616 | |||
startX=0; startY=0; endX=886; endY=616 | |||
</syntaxhighlight> | |||
|also= | |also= | ||
{{func|setViewArea}}, | {{func|setViewArea}}, {{func|goto}}, {{func|setZoom}}, {{func|getZoom}}. | ||
{{func|goto}}, | |||
{{func|setZoom}}, | |change= | ||
{{func|getZoom}}. | {{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]] |
Latest revision as of 23:59, 14 March 2023
getViewArea() Function
• Introduced in version 1.5.0
Returns the limits of the visible area of the map window, given in either map 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 map 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 usingdelim
as a delimiter. Defaults to;
.
Examples
Get the viewport dimensions of the current client:
[r: getViewArea()] <!-- Default pixels -->
[r: getViewArea(0)] <!-- in Grid Cells -->
[r: getViewArea(1)] <!-- in Pixels -->
[r: getViewArea(0, "json")] <!-- Cells as JSON -->
[r: getViewArea(1, "json")] <!-- Pixels as JSON -->
[r: getViewArea(0, ",")] <!-- Cells as "," separated String properties: -->
[r: getViewArea(1, ";")] <!-- Pixels as ";" separated String properties: -->
Output:
startX=0; startY=0; endX=886; endY=616
startX=0; startY=0; endX=17; endY=12
startX=0; startY=0; endX=886; endY=616
{"startX":0,"startY":0,"endX":886,"endY":616}
{"startX":0,"startY":0,"endX":886,"endY":616}
startX=0, startY=0, endX=886, endY=616
startX=0; startY=0; endX=886; endY=616