Initialize the Rotated Coordinate System (screen.init)
Declaration
previousCoordinateSystem = screen.init(orientation)
Parameters
- orientation
Integer value.
0 means portrait with Home at the bottom
1 means landscape with Home on the right
2 means landscape with Home on the left
3 means portrait with Home at the top
Returns
- previousCoordinateSystem
Integer value that represents the coordinate system in use before this call.
Description
Initializes the coordinate system used when sampling colors or performing touch actions.
This setting affects how coordinate parameters and return values are interpreted by the following functions:
screen.get_color
screen.is_colors
screen.find_color
screen.ocr_text
screen.image
touch.on
touch.move
touch.off
touch.tap
Using an iPhone 8 as the example (750x1334 resolution):
Default portrait coordinate system, screen.init(0)
(0,0) physical top-left corner
┌──────────────────────────────────▶ x+
│ │
│
│ │
│
│ │
│
│ │
│
│ │
│
│ │
│
│ │
│
│ │
│
│ │
│
▼ y+ ▼
(750,1334) physical bottom-right corner
┌──────────────────────────────────┐
│ Home │
└──────────────────────────────────┘
Landscape with Home on the right, screen.init(1)
(0,0)
┌────────────────────────────────────────────────▶ x+ physical bottom-right corner
│ │ ┌───┐
│ │ │
│ │ │ │
│ │ │
│ │ │ │
│ │ H │
│ │ │ o │
│ │ m │
│ │ │ e │
│ │ │
│ │ │ │
│ │ │
│ │ │ │
│ │ └───┘
▼ y+ ▼
physical top-left corner (1334,750)
Landscape with Home on the left, screen.init(2)
(0,0)
┌────────────────────────────────────────────────▶ x+ physical top-left corner
┌───┐ │ │
│ │ │
│ │ │ │
│ │ │
│ │ │ │
│ H │ │
│ o │ │ │
│ m │ │
│ e │ │ │
│ │ │
│ │ │ │
│ │ │
│ │ │ │
└───┘ │ │
▼ y+ ▼
physical bottom-right corner (1334,750)
Portrait with Home at the top, screen.init(3)
┌──────────────────────────────────┐
│ Home │
└──────────────────────────────────┘
(0,0) physical bottom-right corner
┌──────────────────────────────────▶ x+
│ │
│
│ │
│
│ │
│
│ │
│
│ │
│
│ │
│
│ │
│
│ │
│
│ │
│
▼ y+ ▼
(750,1334) physical top-left corner
Example
screen.init(0) -- Home at the bottom
screen.init(1) -- Home on the right
screen.init(2) -- Home on the left
screen.init(3) -- Home at the top
The following aliases have the same effect:
screen.init_home_on_bottom() -- Home at the bottom
screen.init_home_on_right() -- Home on the right
screen.init_home_on_left() -- Home on the left
screen.init_home_on_top() -- Home at the top