Skip to main content
TapKit provides coordinate classes for working with screen positions. Use Point for absolute pixel coordinates and NormalizedPoint for relative positions.

Point

Represents absolute pixel coordinates on the screen:
from tapkit.geometry import Point

# Create a point
p = Point(100, 200)

print(p.x)  # 100
print(p.y)  # 200

Properties

PropertyTypeDescription
xintX coordinate in pixels
yintY coordinate in pixels

Usage

Points work seamlessly with all TapKit actions:
from tapkit.geometry import Point

point = Point(100, 200)

# Use directly in actions
phone.tap(point)
phone.double_tap(point)
phone.flick(point, direction="up")

Tuple Unpacking

Points support tuple unpacking:
point = Point(100, 200)

# Unpack to variables
x, y = point

# Index access
point[0]  # 100
point[1]  # 200

# Convert to tuple
point.as_tuple()  # (100, 200)

Distance Calculation

Calculate distance between points:
p1 = Point(0, 0)
p2 = Point(100, 100)

distance = p1.distance_to(p2)  # 141.42...

NormalizedPoint

Represents coordinates as 0.0-1.0 values relative to screen dimensions. Useful when working with vision models.
from tapkit.geometry import NormalizedPoint

# Center of screen (50%, 50%)
center = NormalizedPoint(0.5, 0.5)

# Top-left corner
top_left = NormalizedPoint(0.0, 0.0)

# Bottom-right corner
bottom_right = NormalizedPoint(1.0, 1.0)

Convert to Absolute

Convert normalized coordinates to absolute pixels:
norm_point = NormalizedPoint(0.5, 0.5)

# Convert using screen dimensions
abs_point = norm_point.to_absolute(width=1170, height=2532)

print(abs_point)  # Point(x=585, y=1266)
phone.tap(abs_point)
Or use the phone’s dimensions:
norm_point = NormalizedPoint(0.5, 0.5)
abs_point = norm_point.to_absolute(phone.width, phone.height)
phone.tap(abs_point)

From Different Scales

Vision models often use different coordinate scales:
# From 0-1000 scale (common in some models)
norm = NormalizedPoint.from_1000_scale(500, 300)

# From 0-100 percentage scale
norm = NormalizedPoint.from_100_scale(50, 30)

# From absolute coordinates
norm = NormalizedPoint.from_absolute(
    Point(585, 760),
    width=1170,
    height=2532
)

Properties

PropertyTypeDescription
xfloatX coordinate (0.0-1.0)
yfloatY coordinate (0.0-1.0)

Methods

MethodReturnsDescription
to_absolute(width, height)PointConvert to absolute pixels
from_1000_scale(x, y)NormalizedPointCreate from 0-1000 coordinates
from_100_scale(x, y)NormalizedPointCreate from 0-100 percentages
from_absolute(point, w, h)NormalizedPointCreate from absolute point

Examples

Vision Model Integration

# Model returns coordinates in 0-1000 scale
model_x, model_y = 523, 847

# Convert to normalized
norm = NormalizedPoint.from_1000_scale(model_x, model_y)

# Convert to absolute and tap
abs_point = norm.to_absolute(phone.width, phone.height)
phone.tap(abs_point)

Percentage-Based Positioning

# Tap at 25% from left, 75% from top
target = NormalizedPoint(0.25, 0.75)
phone.tap(target.to_absolute(phone.width, phone.height))

Store Positions Relatively

# Store button position as normalized
button_norm = NormalizedPoint(0.5, 0.9)

# Works on any device size
phone1 = client.phone("iPhone 15 Pro")
phone2 = client.phone("iPhone SE")

# Same relative position on both
phone1.tap(button_norm.to_absolute(phone1.width, phone1.height))
phone2.tap(button_norm.to_absolute(phone2.width, phone2.height))

Next Steps