getViewCenter: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{MacroFunction |name= getViewCenter |version=1.5.4 |description= Returns the limits of the visible area of the map window, given in either pixels or cell coordinates dependin...") |
m (Text replacement - "<source" to "<syntaxhighlight") |
||
(5 intermediate revisions by 4 users not shown) | |||
Line 3: | Line 3: | ||
|version=1.5.4 | |version=1.5.4 | ||
|description= | |description= | ||
Returns the | Returns the center 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> | ||
getViewCenter() | getViewCenter() | ||
getViewCenter(pixels) | getViewCenter(pixels) | ||
getViewCenter(pixels, delim) | getViewCenter(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. Defaults to {{code|true}}. | * {{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|;}}. | * {{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 | Get the center of the view of the current client: | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[r: getViewCenter()] <!-- Default pixels --> | [r: getViewCenter()] <!-- Default pixels --> | ||
[r: getViewCenter(0)] <!-- in Grid Cells --> | [r: getViewCenter(0)] <!-- in Grid Cells --> | ||
Line 26: | Line 26: | ||
[r: getViewCenter(0, ",")] <!-- Cells as "," separated String properties: --> | [r: getViewCenter(0, ",")] <!-- Cells as "," separated String properties: --> | ||
[r: getViewCenter(1, ";")] <!-- Pixels as ";" separated String properties: --> | [r: getViewCenter(1, ";")] <!-- Pixels as ";" separated String properties: --> | ||
</ | </syntaxhighlight> | ||
Output: | Output: | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
centerX=646; centerY=319; | centerX=646; centerY=319; | ||
centerX=14; centerY=7; | centerX=14; centerY=7; | ||
Line 37: | Line 37: | ||
centerX=14, centerY=7; | centerX=14, centerY=7; | ||
centerX=646; centerY=319, | centerX=646; centerY=319, | ||
</ | </syntaxhighlight> | ||
|also= | |also= |
Latest revision as of 21:11, 14 March 2023
getViewCenter() Function
• Introduced in version 1.5.4
Returns the center 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
getViewCenter()
getViewCenter(pixels)
getViewCenter(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 center of the view of the current client:
[r: getViewCenter()] <!-- Default pixels -->
[r: getViewCenter(0)] <!-- in Grid Cells -->
[r: getViewCenter(1)] <!-- in Pixels -->
[r: getViewCenter(0, "json")] <!-- Cells as JSON -->
[r: getViewCenter(1, "json")] <!-- Pixels as JSON -->
[r: getViewCenter(0, ",")] <!-- Cells as "," separated String properties: -->
[r: getViewCenter(1, ";")] <!-- Pixels as ";" separated String properties: -->
Output:
centerX=646; centerY=319;
centerX=14; centerY=7;
centerX=646; centerY=319;
{"centerX":14,"centerY":7}
{"centerX":646,"centerY":319}
centerX=14, centerY=7;
centerX=646; centerY=319,