PMAP: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Created page with "The '''PMAP''' statement returns the physical or WINDOW view port coordinates. {{PageSyntax}} :: PMAP (''coordinate'', ''function_number%'') * The ''coordinate'' is the coordinate point to be mapped. * The ''function'' can have one of four values: :: 0 = Maps view port coordinate to physical x screen coordinate :: 1 = Maps view port coordinate to physical y screen coordinate :: 2 = Maps physical screen coordinate to view port x coordinate :: 3 = Maps physical...")
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
The '''PMAP''' statement returns the physical or [[WINDOW]] view port coordinates.
The '''PMAP''' statement returns the physical or [[WINDOW]] view port coordinates.




Line 7: Line 6:




* The ''coordinate'' is the coordinate point to be mapped.  
* The ''coordinate'' is the coordinate point to be mapped.
* The ''function'' can have one of four values:
* The ''function'' can have one of four values:


Line 20: Line 19:


''Example:'' Use PMAP to convert coordinate values from view to screen coordinates and from screen coordinates to view coordinates.
''Example:'' Use PMAP to convert coordinate values from view to screen coordinates and from screen coordinates to view coordinates.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|SCREEN (statement)|SCREEN}} 12
{{Cl|SCREEN}} 12
  'Coordinates of upper-left corner of the window is defined in following statement are (90,100)  
  'Coordinates of upper-left corner of the window is defined in following statement are (90,100)
{{Cl|WINDOW}} {{Cl|SCREEN (statement)|SCREEN}} (90, 100)-(200, 200) 'coordinates of lower-right 'corner are 200, 200.
{{Cl|WINDOW}} {{Cl|SCREEN}} (90, 100)-(200, 200) 'coordinates of lower-right 'corner are 200, 200.


X = {{Cl|PMAP}}(90, 0)          ' X = 0
X = {{Cl|PMAP}}(90, 0)          ' X = 0
Line 51: Line 50:
{{Cl|CLS}} 1                    ' clear grahic view port
{{Cl|CLS}} 1                    ' clear grahic view port
{{Cl|WINDOW}}                  ' end graphic view port
{{Cl|WINDOW}}                  ' end graphic view port
{{Cl|END}} '' ''
{{Cl|END}}
{{CodeEnd}}
{{CodeEnd}}
: ''Note:'' If physical screen coordinates are (0, 0) in the upper-left corner and (639, 479) in the lower-right corner, then the statements return the screen coordinate's equal to the view coordinates 90, 100.
: ''Note:'' If physical screen coordinates are (0, 0) in the upper-left corner and (639, 479) in the lower-right corner, then the statements return the screen coordinate's equal to the view coordinates 90, 100.




''See also:''
{{PageSeeAlso}}
* [[WINDOW]], [[VIEW]]
* [[WINDOW]], [[VIEW]]
* [[VIEW PRINT]]
* [[VIEW PRINT]]

Latest revision as of 00:53, 29 January 2023

The PMAP statement returns the physical or WINDOW view port coordinates.


Syntax

PMAP (coordinate, function_number%)


  • The coordinate is the coordinate point to be mapped.
  • The function can have one of four values:
0 = Maps view port coordinate to physical x screen coordinate
1 = Maps view port coordinate to physical y screen coordinate
2 = Maps physical screen coordinate to view port x coordinate
3 = Maps physical screen coordinate to view port y coordinate
  • The four PMAP functions allow the user to find equal point locations between the view coordinates created with the WINDOW statement and the physical screen coordinates of the viewport as defined by the VIEW statement.
  • Mouse co-ordinates returned by _MOUSEX and _MOUSEY are the physical screen co-ordinates.


Example: Use PMAP to convert coordinate values from view to screen coordinates and from screen coordinates to view coordinates.

SCREEN 12
 'Coordinates of upper-left corner of the window is defined in following statement are (90,100)
WINDOW SCREEN (90, 100)-(200, 200) 'coordinates of lower-right 'corner are 200, 200.

X = PMAP(90, 0)          ' X = 0
PRINT X
Y = PMAP(100, 1)         ' Y = 0
PRINT Y

'These statements return the screen coordinates equal to the view coordinates 200, 200.
X = PMAP(200, 0)         ' X = 639
PRINT X
Y = PMAP(200, 1)         ' Y = 479
PRINT Y

'These statements return the view coordinates equal to the screen coordinates 0, 0
X = PMAP(0, 0)
PRINT X
Y = PMAP(0, 0)
PRINT Y

'These statements return the view coordinates equal to the screen coordinates 639, 479.
X = PMAP(639, 2)         ' X = 200
PRINT X
Y = PMAP(479, 3)         ' Y = 200
PRINT Y

SLEEP                    ' pause before clearing view port
CLS 1                    ' clear grahic view port
WINDOW                   ' end graphic view port
END
Note: If physical screen coordinates are (0, 0) in the upper-left corner and (639, 479) in the lower-right corner, then the statements return the screen coordinate's equal to the view coordinates 90, 100.


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link