getViewArea: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page GetViewArea to getViewArea: Converting page titles to lowercase)
m (Text replacement - "source>" to "syntaxhighlight>")
Line 10: Line 10:
getViewArea(pixels)
getViewArea(pixels)
getViewArea(pixels, delim)
getViewArea(pixels, delim)
</source>
</syntaxhighlight>


'''Parameters'''
'''Parameters'''
Line 26: Line 26:
[r: getViewArea(0, ",")] <!-- Cells as "," separated String properties: -->
[r: getViewArea(0, ",")] <!-- Cells as "," separated String properties: -->
[r: getViewArea(1, ";")] <!-- Pixels as ";" separated String properties: -->
[r: getViewArea(1, ";")] <!-- Pixels as ";" separated String properties: -->
</source>
</syntaxhighlight>


Output:
Output:
Line 37: Line 37:
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
</source>
</syntaxhighlight>


|also=
|also=

Revision as of 20:07, 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

<source lang="mtmacro" line> getViewArea() getViewArea(pixels) getViewArea(pixels, delim) </syntaxhighlight>

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 to true.
  • 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. Defaults to ;.

Examples

Get the viewport dimensions of the current client:

<source lang="mtmacro" line> [r: getViewArea()] [r: getViewArea(0)] [r: getViewArea(1)] [r: getViewArea(0, "json")] [r: getViewArea(1, "json")] [r: getViewArea(0, ",")] [r: getViewArea(1, ";")] </syntaxhighlight>

Output: <source 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>

See Also