getViewArea: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
(The output area is for showing the actual macro output. The line #'s correspond with those of the macro code. Undo revision 7284 by Naciron (talk))
Line 30: Line 30:
Output:
Output:
<source lang="mtmacro" line>
<source lang="mtmacro" line>
Default pixels: offsetX=133; offsetY=116; width=886; height=616
offsetX=0; offsetY=0; width=886; height=616  
Cells: offsetX=2; offsetY=2; width=17; height=12
offsetX=0; offsetY=0; width=17; height=12  
Pixels: offsetX=133; offsetY=116; width=886; height=616
offsetX=0; offsetY=0; width=886; height=616  
Cells as JSON: {"offsetX":2,"offsetY":2,"width":17,"height":12}
{"offsetX":0,"offsetY":0,"width":886,"height":616}  
Pixels as JSON: {"offsetX":133,"offsetY":116,"width":886,"height":616}
{"offsetX":0,"offsetY":0,"width":886,"height":616}  
Cells as "," separated String properties: offsetX=2, offsetY=2, width=17, height=12
offsetX=0, offsetY=0, width=886, height=616
Pixels as ";" separated String properties: offsetX=133; offsetY=116; width=886; height=616
offsetX=0; offsetY=0; width=886; height=616
</source>
</source>



Revision as of 15:27, 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 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:
[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:

offsetX=0; offsetY=0; width=886; height=616 
offsetX=0; offsetY=0; width=17; height=12 
offsetX=0; offsetY=0; width=886; height=616 
{"offsetX":0,"offsetY":0,"width":886,"height":616} 
{"offsetX":0,"offsetY":0,"width":886,"height":616} 
offsetX=0, offsetY=0, width=886, height=616 
offsetX=0; offsetY=0; width=886; height=616

See Also