Runtime v2.81 · Updated Sep 30, 2026

Region

A rectangular region on the screen, measured in pixels on the current screen axes.

Syntax

Region(x, y, width, height, /, scale="fixed", anchor="none", scale_param=ScaleParam())

Constructor parameters

NameDescription
xNumber
Top-left X coordinate
Required · Positional only
No default
yNumber
Top-left Y coordinate
Required · Positional only
No default
widthNumber
Region width
Required · Positional only
No default
heightNumber
Region height
Required · Positional only
No default
scaleString
**Applies to region coordinates**. Optional full-screen scale mode on the current X/Y axes. Values: "fixed", "auto", "width", "height".
Optional · Positional or named
Default: fixed
anchorString
**Applies to region coordinates**. Optional anchor mode. Values: none, center, top, bottom, left, right, top_left, top_right, bottom_left, bottom_right, auto.
Optional · Positional or named
Default: none
scale_paramScaleParam
**Applies to templates**. Template matching scale parameters.
Optional · Positional or named
Default: ScaleParam()

Returns

Region

Behavior / side effects

A rectangular region on the screen, measured in pixels on the current screen axes. Scale/anchor control coordinate mapping across full-screen sizes without rotating through portrait coordinates or using the app viewport; runtime consumers clip the final region to the current screen after mapping and offsets. ScaleParam controls template matching inside this region. Region can be destructured as x, y, width, height.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Constructs or derives geometry in the calling flow without capture or recognition. Keep mutable Region builders local to each flow.

Example

region = Region(100, 200, 300, 400)
hit = region.find("img", 3000, threshold=0.8, rate=3.0)

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

None

Fields

NameDescription
xNumber
Top-left horizontal coordinate.
yNumber
Top-left vertical coordinate.
widthNumber
Region width in pixels.
heightNumber
Region height in pixels.
scaleString
**Applies to region coordinates**. Coordinate scale mode using full-screen dimensions on the current X/Y axes, without app viewport scaling or portrait rotation. Values: "fixed" keeps saved pixels unchanged; "auto" scales X by width and Y by height; "width" scales both axes by screen width; "height" scales both axes by screen height.
Default: fixed
anchorString
**Applies to region coordinates**. Coordinate anchor. Values: none, center, top, bottom, left, right, top_left, top_right, bottom_left, bottom_right, auto.
Default: none
scale_paramScaleParam
**Applies to templates**. Template matching scale parameters used by find/wait methods on this region.
Default: ScaleParam()
middle_pointPoint
Center point of this region.
Field example
search_area = Region(120, 240, 360, 420)
left = search_area.x
top = search_area.y
w = search_area.width
h = search_area.height
scale = search_area.scale
anchor = search_area.anchor
search_area.x = 300
search_area.scale_param = ScaleParam(auto_scale=True, template_scale="LONG_EDGE")
center = search_area.middle_point

# Unpack Region into x, y, width, height
x, y, width, height = search_area
Constructor example
search_region = Region(120, 240, 360, 420)
fixed_center = Region(120, 240, 360, 420, "fixed", "center")
left_lane = Region(120, 240, 360, 420, scale="width", anchor="left", scale_param=ScaleParam(auto_scale=True, template_scale="LONG_EDGE"))

Methods

25 methods

Region.highlighted

Get all regions currently highlighted by script instances.

Syntax

Region.highlighted()

Parameters

None

Returns

list[Region] — list of active highlighted regions.

Behavior / side effects

Get all regions currently highlighted by script instances.

Execution

  • Blocking: Conditional
  • Thread safety: Not guaranteed
  • Parallel execution: Conditional

Execution cost and waits depend on the documented operation. Keep mutable values in their owning flow; sharing arbitrary objects between flows has no general thread-safety guarantee.

Example

active_regions = Region.highlighted()
for area in active_regions:
    area.highlight("yellow", auto_hide_ms=500)

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.full_screen

Return the full current screen region.

Syntax

Region.full_screen()

Parameters

None

Returns

Region — Screen-sized region from the runtime host.

Behavior / side effects

Return the full current screen region.

Execution

  • Blocking: Conditional
  • Thread safety: Not guaranteed
  • Parallel execution: Conditional

Execution cost and waits depend on the documented operation. Keep mutable values in their owning flow; sharing arbitrary objects between flows has no general thread-safety guarantee.

Example

scan = Region.full_screen()
hit = scan.find("ok", 2000)

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.highlight_off

Turn off all active region highlights.

Syntax

Region.highlight_off()

Parameters

None

Returns

None — No value.

Behavior / side effects

Turn off all active region highlights.

Execution

  • Blocking: Conditional
  • Thread safety: Not guaranteed
  • Parallel execution: Conditional

Execution cost and waits depend on the documented operation. Keep mutable values in their owning flow; sharing arbitrary objects between flows has no general thread-safety guarantee.

Example

scan = Region(120, 260, 280, 160)
scan.highlight("green")
wait(1000)
Region.highlight_off()

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.macro_width

Return the screen width of the device that created this macro, adapted to current screen orientation, when available.

Syntax

Region.macro_width()

Parameters

None

Returns

Number? — Macro source screen width, or None when unavailable.

Behavior / side effects

Return the screen width of the device that created this macro, adapted to current screen orientation, when available.

Execution

  • Blocking: Conditional
  • Thread safety: Not guaranteed
  • Parallel execution: Conditional

Execution cost and waits depend on the documented operation. Keep mutable values in their owning flow; sharing arbitrary objects between flows has no general thread-safety guarantee.

Example

macro_w = Region.macro_width()

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.macro_height

Return the screen height of the device that created this macro, adapted to current screen orientation, when available.

Syntax

Region.macro_height()

Parameters

None

Returns

Number? — Macro source screen height, or None when unavailable.

Behavior / side effects

Return the screen height of the device that created this macro, adapted to current screen orientation, when available.

Execution

  • Blocking: Conditional
  • Thread safety: Not guaranteed
  • Parallel execution: Conditional

Execution cost and waits depend on the documented operation. Keep mutable values in their owning flow; sharing arbitrary objects between flows has no general thread-safety guarantee.

Example

macro_h = Region.macro_height()

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.find

Scan inside this region until one template match is found or timeout is reached.

Syntax

region.find(template, timeout=0, threshold=0.7, rate=3.0)

Parameters

NameDescription
templateString | Template
Template name, relative folder path, or a Template object in current macro.
Required · Positional or named
No default
timeoutNumber
Maximum wait time in milliseconds. Omit this argument to scan only once.
Optional · Positional or named
Default: 0
thresholdNumber
Match threshold from 0.0 to 1.0.
Optional · Positional or named
Default: 0.7
rateNumber
Scan attempts per second (1-60).
Optional · Positional or named
Default: 3.0

Returns

Match — First successful match, or found=false when timed out.

Behavior / side effects

Scan inside this region until one template match is found or timeout is reached. If timeout is omitted, only one scan pass is performed. Use ScreenCapture.cache_on() to check several images in one pinned frame, then cache_off() to unpin it. For rapid recognition with the freshest available frame, also use ScreenCapture.auto_cache_off(); automatic caching otherwise reuses frames for up to 100 ms. Disabling it increases capture work and does not guarantee faster execution.

Execution

  • Blocking: Yes
  • Thread safety: Limited
  • Parallel execution: Conditional

Recognition runs in the caller and uses shared capture. find operations search for appearance; wait operations wait for disappearance. Even a single scan takes capture and recognition time; a timeout or polling rate does not make the call asynchronous.

Example

region = Region(80, 220, 420, 520)
hit = region.find("ok", 4000, 0.8, 4.0)
MacroPanel.notify(str(hit))

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.find_multi

Scan inside this region and return all matches for one template when at least one is found.

Syntax

region.find_multi(template, timeout=0, threshold=0.7, rate=3.0)

Parameters

NameDescription
templateString | Template
Template name, relative folder path, or a Template object in current macro.
Required · Positional or named
No default
timeoutNumber
Maximum wait time in milliseconds. Omit this argument to scan only once.
Optional · Positional or named
Default: 0
thresholdNumber
Match threshold from 0.0 to 1.0.
Optional · Positional or named
Default: 0.7
rateNumber
Scan attempts per second (1-60).
Optional · Positional or named
Default: 3.0

Returns

MatchList — All matches for the template, or empty list on timeout.

Behavior / side effects

Scan inside this region and return all matches for one template when at least one is found. If timeout is omitted, only one scan pass is performed.

Execution

  • Blocking: Yes
  • Thread safety: Limited
  • Parallel execution: Conditional

Recognition runs in the caller and uses shared capture. find operations search for appearance; wait operations wait for disappearance. Even a single scan takes capture and recognition time; a timeout or polling rate does not make the call asynchronous.

Example

region = Region(80, 220, 420, 520)
matches = region.find_multi("enemy", 3000)
MacroPanel.notify(str(matches))

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.find_any

Scan this region and return when any template in the list is found.

Syntax

region.find_any(templates, timeout=0, threshold=0.7, rate=3.0)

Parameters

NameDescription
templateslist[String | Template]
Template names or Template objects.
Required · Positional or named
No default
timeoutNumber
Maximum wait time in milliseconds. Omit this argument to scan only once.
Optional · Positional or named
Default: 0
thresholdNumber
Match threshold from 0.0 to 1.0.
Optional · Positional or named
Default: 0.7
rateNumber
Scan attempts per second (1-60).
Optional · Positional or named
Default: 3.0

Returns

MatchList — Batch match results when any template is found, or empty list on timeout.

Behavior / side effects

Scan this region and return when any template in the list is found. If timeout is omitted, only one scan pass is performed.

Execution

  • Blocking: Yes
  • Thread safety: Limited
  • Parallel execution: Conditional

Recognition runs in the caller and uses shared capture. find operations search for appearance; wait operations wait for disappearance. Even a single scan takes capture and recognition time; a timeout or polling rate does not make the call asynchronous.

Example

region = Region(80, 220, 420, 520)
matches = region.find_any(["enemy_a", "enemy_b"], 2500)
MacroPanel.notify(str(matches))

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.find_all

Scan this region and return only when every template in the list is found.

Syntax

region.find_all(templates, timeout=0, threshold=0.7, rate=3.0)

Parameters

NameDescription
templateslist[String | Template]
Template names or Template objects.
Required · Positional or named
No default
timeoutNumber
Maximum wait time in milliseconds. Omit this argument to scan only once.
Optional · Positional or named
Default: 0
thresholdNumber
Match threshold from 0.0 to 1.0.
Optional · Positional or named
Default: 0.7
rateNumber
Scan attempts per second (1-60).
Optional · Positional or named
Default: 3.0

Returns

MatchList — Batch match results when all templates are found, or empty list on timeout.

Behavior / side effects

Scan this region and return only when every template in the list is found. If timeout is omitted, only one scan pass is performed.

Execution

  • Blocking: Yes
  • Thread safety: Limited
  • Parallel execution: Conditional

Recognition runs in the caller and uses shared capture. find operations search for appearance; wait operations wait for disappearance. Even a single scan takes capture and recognition time; a timeout or polling rate does not make the call asynchronous.

Example

region = Region(80, 220, 420, 520)
matches = region.find_all(["hp", "mp"], 5000)
MacroPanel.notify(str(matches))

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.find_color

Scan this region for one target color using the same raw-frame RGB tolerance rule as UI color recognition.

Syntax

region.find_color(color, timeout=0, tolerance=0, rate=3, interval=10)

Parameters

NameDescription
colorColor | String | Number
Target color.
Required · Positional or named
No default
timeoutNumber
Maximum wait time in milliseconds. 0 performs one scan pass.
Optional · Positional or named
Default: 0
toleranceNumber
Allowed per-channel RGB delta from 0 to 255.
Optional · Positional or named
Default: 0
rateNumber
Scan attempts per second while waiting.
Optional · Positional or named
Default: 3
intervalNumber
Sampling step in pixels.
Optional · Positional or named
Default: 10

Returns

Match — Match with point as list[Point]; find_color returns at most one point.

Behavior / side effects

Scan this region for one target color using the same raw-frame RGB tolerance rule as UI color recognition. The best point is selected by the smallest max RGB channel delta.

Execution

  • Blocking: Yes
  • Thread safety: Limited
  • Parallel execution: Conditional

Recognition runs in the caller and uses shared capture. find operations search for appearance; wait operations wait for disappearance. Even a single scan takes capture and recognition time; a timeout or polling rate does not make the call asynchronous.

Example

scan = Region(80, 220, 420, 520)
hit = scan.find_color("#FF4CAF50", tolerance=8, interval=4)
if hit.found:
    click(hit.point[0], random=0)

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.find_any_color

Scan this region for multiple target colors.

Syntax

region.find_any_color(colors, timeout=0, tolerance=0, rate=3, interval=10)

Parameters

NameDescription
colorslist[Color | String | Number] | tuple[Color | String | Number]
Target colors.
Required · Positional or named
No default
timeoutNumber
Maximum wait time in milliseconds. 0 performs one scan pass.
Optional · Positional or named
Default: 0
toleranceNumber
Allowed per-channel RGB delta from 0 to 255.
Optional · Positional or named
Default: 0
rateNumber
Scan attempts per second while waiting.
Optional · Positional or named
Default: 3
intervalNumber
Sampling step in pixels.
Optional · Positional or named
Default: 10

Returns

Match — Match with point as list[Point]; one best point per found input color.

Behavior / side effects

Scan this region for multiple target colors. Each input color contributes at most one best point, ordered by the input color list.

Execution

  • Blocking: Yes
  • Thread safety: Limited
  • Parallel execution: Conditional

Recognition runs in the caller and uses shared capture. find operations search for appearance; wait operations wait for disappearance. Even a single scan takes capture and recognition time; a timeout or polling rate does not make the call asynchronous.

Example

colors = ["#FF0000", "#00FF00", "#0000FF"]
hit = Region.full_screen().find_any_color(colors, tolerance=6)
if hit.found:
    click(hit, random=0)

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.find_multi_color

Scan this region for multiple sampled positions of one target color.

Syntax

region.find_multi_color(color, timeout=0, tolerance=0, rate=3, interval=10)

Parameters

NameDescription
colorColor | String | Number
Single target color.
Required · Positional or named
No default
timeoutNumber
Maximum wait time in milliseconds. 0 performs one scan pass.
Optional · Positional or named
Default: 0
toleranceNumber
Allowed per-channel RGB delta from 0 to 255.
Optional · Positional or named
Default: 0
rateNumber
Scan attempts per second while waiting.
Optional · Positional or named
Default: 3
intervalNumber
Sampling step in pixels.
Optional · Positional or named
Default: 10

Returns

Match — Match with point as list[Point]; matching sampled points are sorted with the closest color first.

Behavior / side effects

Scan this region for multiple sampled positions of one target color. Passing a list or tuple is rejected so this does not silently become multi-target color search.

Execution

  • Blocking: Yes
  • Thread safety: Limited
  • Parallel execution: Conditional

Recognition runs in the caller and uses shared capture. find operations search for appearance; wait operations wait for disappearance. Even a single scan takes capture and recognition time; a timeout or polling rate does not make the call asynchronous.

Example

hit = Region(80, 220, 420, 520).find_multi_color("red", tolerance=4, interval=3)
if hit.found:
    first = hit.point[0]
    hit.highlight(color="yellow", auto_hide_ms=800)

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.wait

Wait until the template disappears from this region.

Syntax

region.wait(template, timeout=0, threshold=0.7, rate=3.0)

Parameters

NameDescription
templateString | Template
Template name, relative folder path, or a Template object in current macro.
Required · Positional or named
No default
timeoutNumber
Maximum wait time in milliseconds. Omit this argument to scan only once.
Optional · Positional or named
Default: 0
thresholdNumber
Match threshold from 0.0 to 1.0.
Optional · Positional or named
Default: 0.7
rateNumber
Scan attempts per second (1-60).
Optional · Positional or named
Default: 3.0

Returns

Match — Latest match state when the template disappears or timeout is reached.

Behavior / side effects

Wait until the template disappears from this region. If timeout is omitted, only one scan pass is performed.

Execution

  • Blocking: Yes
  • Thread safety: Limited
  • Parallel execution: Conditional

Recognition runs in the caller and uses shared capture. find operations search for appearance; wait operations wait for disappearance. Even a single scan takes capture and recognition time; a timeout or polling rate does not make the call asynchronous.

Example

region = Region(0, 0, 1080, 2400)
result = region.wait("loading", 8000)
MacroPanel.notify(str(result))

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.wait_any

Wait until any template in the list disappears from this region.

Syntax

region.wait_any(templates, timeout=0, threshold=0.7, rate=3.0)

Parameters

NameDescription
templateslist[String | Template]
Template names or Template objects.
Required · Positional or named
No default
timeoutNumber
Maximum wait time in milliseconds. Omit this argument to scan only once.
Optional · Positional or named
Default: 0
thresholdNumber
Match threshold from 0.0 to 1.0.
Optional · Positional or named
Default: 0.7
rateNumber
Scan attempts per second (1-60).
Optional · Positional or named
Default: 3.0

Returns

MatchList — Batch match states when at least one template is no longer found.

Behavior / side effects

Wait until any template in the list disappears from this region. If timeout is omitted, only one scan pass is performed.

Execution

  • Blocking: Yes
  • Thread safety: Limited
  • Parallel execution: Conditional

Recognition runs in the caller and uses shared capture. find operations search for appearance; wait operations wait for disappearance. Even a single scan takes capture and recognition time; a timeout or polling rate does not make the call asynchronous.

Example

watch = ["loading", "syncing"]
result = region.wait_any(watch, 10000)
MacroPanel.notify(str(result))

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.wait_all

Wait until all templates in the list disappear from this region.

Syntax

region.wait_all(templates, timeout=0, threshold=0.7, rate=3.0)

Parameters

NameDescription
templateslist[String | Template]
Template names or Template objects.
Required · Positional or named
No default
timeoutNumber
Maximum wait time in milliseconds. Omit this argument to scan only once.
Optional · Positional or named
Default: 0
thresholdNumber
Match threshold from 0.0 to 1.0.
Optional · Positional or named
Default: 0.7
rateNumber
Scan attempts per second (1-60).
Optional · Positional or named
Default: 3.0

Returns

MatchList — Batch match states when all templates are no longer found.

Behavior / side effects

Wait until all templates in the list disappear from this region. If timeout is omitted, only one scan pass is performed.

Execution

  • Blocking: Yes
  • Thread safety: Limited
  • Parallel execution: Conditional

Recognition runs in the caller and uses shared capture. find operations search for appearance; wait operations wait for disappearance. Even a single scan takes capture and recognition time; a timeout or polling rate does not make the call asynchronous.

Example

watch = ["loading", "syncing"]
result = region.wait_all(watch, 10000)
MacroPanel.notify(str(result))

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.capture

Capture the screen and crop to this region, then return the result as a Template.

Syntax

region.capture(name=None)

Parameters

NameDescription
nameString?
Optional template name to save into current macro immediately.
Optional · Positional or named
Default: None

Returns

Template — Captured template object.

Behavior / side effects

Capture the screen and crop to this region, then return the result as a Template.

Execution

  • Blocking: Yes
  • Thread safety: Limited
  • Parallel execution: Conditional

Recognition runs in the caller and uses shared capture. find operations search for appearance; wait operations wait for disappearance. Even a single scan takes capture and recognition time; a timeout or polling rate does not make the call asynchronous.

Example

sample = Region(120, 280, 220, 120).capture()
saved = sample.save_as("buttons/top/enemy_slot")

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.left

Shrink this region toward the left side.

Syntax

region.left(value=0.5)

Parameters

NameDescription
valueNumber
Shrink amount: 0 -> 1 means ratio of current width, >1 means pixels.
Optional · Positional or named
Default: 0.5

Returns

Region — A new region narrowed from the right edge.

Behavior / side effects

Shrink this region toward the left side. The right edge moves left by the requested amount.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Constructs or derives geometry in the calling flow without capture or recognition. Keep mutable Region builders local to each flow.

Example

full = Region(100, 200, 1000, 500)
left_focus = full.left(0.4)
left_focus_px = full.left(400)

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.right

Shrink this region toward the right side.

Syntax

region.right(value=0.5)

Parameters

NameDescription
valueNumber
Shrink amount: 0 -> 1 means ratio of current width, >1 means pixels.
Optional · Positional or named
Default: 0.5

Returns

Region — A new region narrowed from the left edge.

Behavior / side effects

Shrink this region toward the right side. The left edge moves right by the requested amount.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Constructs or derives geometry in the calling flow without capture or recognition. Keep mutable Region builders local to each flow.

Example

full = Region(100, 200, 1000, 500)
right_focus = full.right(0.3)
right_focus_px = full.right(240)

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.top

Shrink this region toward the top side.

Syntax

region.top(value=0.5)

Parameters

NameDescription
valueNumber
Shrink amount: 0 -> 1 means ratio of current height, >1 means pixels.
Optional · Positional or named
Default: 0.5

Returns

Region — A new region narrowed from the bottom edge.

Behavior / side effects

Shrink this region toward the top side. The bottom edge moves upward by the requested amount.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Constructs or derives geometry in the calling flow without capture or recognition. Keep mutable Region builders local to each flow.

Example

full = Region(100, 200, 1000, 500)
top_focus = full.top(0.25)
top_focus_px = full.top(120)

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.bottom

Shrink this region toward the bottom side.

Syntax

region.bottom(value=0.5)

Parameters

NameDescription
valueNumber
Shrink amount: 0 -> 1 means ratio of current height, >1 means pixels.
Optional · Positional or named
Default: 0.5

Returns

Region — A new region narrowed from the top edge.

Behavior / side effects

Shrink this region toward the bottom side. The top edge moves downward by the requested amount.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Constructs or derives geometry in the calling flow without capture or recognition. Keep mutable Region builders local to each flow.

Example

full = Region(100, 200, 1000, 500)
bottom_focus = full.bottom(0.25)
bottom_focus_px = full.bottom(120)

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.horizontal

Shrink horizontally toward the center by moving both left and right edges inward.

Syntax

region.horizontal(value=0.5)

Parameters

NameDescription
valueNumber
Total horizontal shrink: 0 -> 1 means ratio of current width, >1 means pixels.
Optional · Positional or named
Default: 0.5

Returns

Region — A centered region with reduced width.

Behavior / side effects

Shrink horizontally toward the center by moving both left and right edges inward.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Constructs or derives geometry in the calling flow without capture or recognition. Keep mutable Region builders local to each flow.

Example

full = Region(100, 200, 1000, 500)
center_lane = full.horizontal(0.5)
center_lane_px = full.horizontal(300)

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.vertical

Shrink vertically toward the center by moving both top and bottom edges inward.

Syntax

region.vertical(value=0.5)

Parameters

NameDescription
valueNumber
Total vertical shrink: 0 -> 1 means ratio of current height, >1 means pixels.
Optional · Positional or named
Default: 0.5

Returns

Region — A centered region with reduced height.

Behavior / side effects

Shrink vertically toward the center by moving both top and bottom edges inward.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Constructs or derives geometry in the calling flow without capture or recognition. Keep mutable Region builders local to each flow.

Example

full = Region(100, 200, 1000, 500)
center_band = full.vertical(0.5)
center_band_px = full.vertical(200)

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.middle

Shrink both width and height toward the center.

Syntax

region.middle(value=0.5)

Parameters

NameDescription
valueNumber
Shrink amount for both axes: 0 -> 1 means ratio per axis, >1 means pixels per axis.
Optional · Positional or named
Default: 0.5

Returns

Region — A centered region reduced on both axes.

Behavior / side effects

Shrink both width and height toward the center.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Constructs or derives geometry in the calling flow without capture or recognition. Keep mutable Region builders local to each flow.

Example

full = Region(100, 200, 1000, 500)
focus = full.middle(0.4)
focus_px = full.middle(160)

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.highlight

Draw a highlighted rectangle for this region.

Syntax

region.highlight(color="green", line_width=2, auto_hide_ms=0, movable=False)

Parameters

NameDescription
colorColor | String | Number
Highlight color.
Optional · Positional or named
Default: green
line_widthNumber
Stroke thickness in dp.
Optional · Positional or named
Default: 2
auto_hide_msNumber
Auto-hide after N milliseconds. 0 disables auto-hide.
Optional · Positional or named
Default: 0
movableBoolean
Allow dragging the highlighted region and write the moved coordinates back into this Region.
Optional · Positional or named
Default: False

Returns

Region — Returns the same region after drawing highlight.

Behavior / side effects

Draw a highlighted rectangle for this region. With movable=True, the user can drag the region and the same Region object receives the updated screen coordinates. Re-highlighting the same region instance replaces the previous one.

Execution

  • Blocking: Conditional
  • Thread safety: Not guaranteed
  • Parallel execution: Conditional

Execution cost and waits depend on the documented operation. Keep mutable values in their owning flow; sharing arbitrary objects between flows has no general thread-safety guarantee.

Example

scan = Region(120, 260, 280, 160)
scan.highlight("#FF00BCD4", line_width=3, auto_hide_ms=1500, movable=True)

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Region.highlight_off

Turn off highlight for this region instance.

Syntax

region.highlight_off()

Parameters

None

Returns

Region — Returns the same region after turning highlight off.

Behavior / side effects

Turn off highlight for this region instance.

Execution

  • Blocking: Conditional
  • Thread safety: Not guaranteed
  • Parallel execution: Conditional

Execution cost and waits depend on the documented operation. Keep mutable values in their owning flow; sharing arbitrary objects between flows has no general thread-safety guarantee.

Example

scan = Region(120, 260, 280, 160)
scan.highlight("green")
wait(1000)
scan.highlight_off()

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs