-
Notifications
You must be signed in to change notification settings - Fork 21
[Iris 2.0] Smart region handling
Smart region handling
Ioana Crisan
The get_matrix(m,n) method acts on the current region and returns a "matrix" object(a list of lists) containing new Region objects representing that Region's subdivisions.
Example:
If a Region named r is 100 x 100 pixels at coordinates (0, 0), the call to
r.get_matrix(2,2) will return a matrix of 2 by 2 elements, with each element
sized to 50 x 50 pixels.
[ [ Region(0,0,50,50), Region(50,0,50,50) ],
[ Region(0,50,50,50), Region(50,50,50,50) ] ]
User can use some reserved getter properties to take advantage of this feature and not being required to permanently create new regions for each test case/helper method that he writes.
Example:
screen_region = Region(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)
TOP_HALF = Region.screen_regions(screen_region, 'TOP_HALF')
BOTTOM_HALF = Region.screen_regions(screen_region, 'BOTTOM_HALF')
LEFT_HALF = Region.screen_regions(screen_region, 'LEFT_HALF')
RIGHT_HALF = Region.screen_regions(screen_region, 'RIGHT_HALF')
TOP_THIRD = Region.screen_regions(screen_region, 'TOP_THIRD')
MIDDLE_THIRD_HORIZONTAL = Region.screen_regions(screen_region, 'MIDDLE_THIRD_HORIZONTAL')
BOTTOM_THIRD = Region.screen_regions(screen_region, 'BOTTOM_THIRD')
LEFT_THIRD = Region.screen_regions(screen_region, 'LEFT_THIRD')
MIDDLE_THIRD_VERTICAL = Region.screen_regions(screen_region, 'MIDDLE_THIRD_VERTICAL')
RIGHT_THIRD = Region.screen_regions(screen_region, 'RIGHT_THIRD')
UPPER_LEFT_CORNER = Region.screen_regions(screen_region, 'UPPER_LEFT_CORNER')
UPPER_RIGHT_CORNER = Region.screen_regions(screen_region, 'UPPER_RIGHT_CORNER')
BOTTOM_LEFT_CORNER = Region.screen_regions(screen_region, 'BOTTOM_LEFT_CORNER')
BOTTOM_RIGHT_CORNER = Region.screen_regions(screen_region, 'BOTTOM_RIGHT_CORNER')
@staticmethod
def screen_regions(region, caption):
captions = {
'TOP_HALF': Region.get_matrix(1, 2, region)[0][0],
'BOTTOM_HALF': Region.get_matrix(1, 2, region)[1][0],
'LEFT_HALF': Region.get_matrix(2, 1, region)[0][0],
'RIGHT_HALF': Region.get_matrix(2, 1, region)[0][1],
'TOP_THIRD': Region.get_matrix(1, 3, region)[0][0],
'MIDDLE_THIRD_HORIZONTAL': Region.get_matrix(1, 3, region)[1][0],
'BOTTOM_THIRD': Region.get_matrix(1, 3, region)[2][0],
'LEFT_THIRD': Region.get_matrix(3, 1, region)[0][0],
'MIDDLE_THIRD_VERTICAL': Region.get_matrix(3, 1, region)[0][1],
'RIGHT_THIRD': Region.get_matrix(3, 1, region)[0][2],
'UPPER_LEFT_CORNER': Region.get_matrix(2, 2, region)[0][0],
'UPPER_RIGHT_CORNER': Region.get_matrix(2, 2, region)[0][1],
'BOTTOM_LEFT_CORNER': Region.get_matrix(2, 2, region)[1][0],
'BOTTOM_RIGHT_CORNER': Region.get_matrix(2, 2, region)[1][1],
}
return captions.get(caption)
Usage:
my_region = Screen.TOP_HALF
is_found = exists(my_pattern, my_region)
even_smaller = my_region.top_half()
is_found = exists(another_pattern, even_smaller)
- Overview
More details about how you will create this feature.
- Sample code
TBD
-
New and/or changed files and directories
-
Control Center
This feature is not available in the Control Center, so no impact.
-
Localization
-
Documentation
-
Bootstrap
No changes are required to the bootstrap scripts.
- Setup
No changes are required to the setup scripts.
- Dependencies on other people/teams/software.
No known dependencies.
- Other factors that could influence functionality or schedule.
- xxxx-xx-xx Spec due date (this)
- xxxx-xx-xx Implementation
- xxxx-xx-xx Code review
- xxxx-xx-xx Testing
- xxxx-xx-xx Final check-in date
Installation
Running Iris
- Basic workflow
- Useful examples
- Using the Control Center - coming soon
- Runtime argument list - coming soon
Contributing to Iris
- Iris APIs - coming soon
- Creating images
- Code style guide - coming soon
- Getting code into Iris
- Communicating with the team - coming soon