User Rating 0.0 โ˜…โ˜…โ˜…โ˜…โ˜…
Total Usage 0 times
Bounds [x, y, width, height]
Range & Options
Input Coordinate
Enter values and press Convert
Is this tool helpful?

Your feedback helps us improve.

โ˜… โ˜… โ˜… โ˜… โ˜…

About

Mapping absolute pixel coordinates to normalized relative offsets is a routine requirement in HID digitizer drivers, touch-panel firmware, and game-engine input pipelines. The standard range 0 - 65535 (0xFFFF) originates from the USB HID specification for absolute pointing devices. A miscalculated offset shifts cursor registration across the entire display surface - on a 3840ร—2160 panel, a single-bit error at the high end of the range corresponds to roughly 0.06 px, but at coarser ranges the error budget grows fast. This tool computes r = ((p โˆ’ o) รท s) ร— R with explicit clamping, batch input, and an inverse mode that recovers absolute coordinates from relative values. It assumes a linear, axis-aligned bounding rectangle; rotated or perspective-distorted bounds require affine correction not covered here.

coordinate converter relative offset bounds mapping HID digitizer normalized coordinates touch input mapping

Formulas

The forward conversion maps an absolute coordinate p into the relative range [0, R] given a bounding rectangle with origin o and size s:

r = clamp(p โˆ’ os ร— R, 0, R)

The inverse conversion recovers the absolute coordinate from a relative offset:

p = rR ร— s + o

Applied independently per axis:

rx = clamp(px โˆ’ x0w ร— R, 0, R)
ry = clamp(py โˆ’ y0h ร— R, 0, R)

Where: px, py = absolute input coordinates. x0, y0 = bounding rectangle origin (top-left). w, h = bounding rectangle width and height. R = maximum range value (default 65535). rx, ry = resulting relative offsets. clamp restricts output to [0, R], preventing out-of-bounds values when the input coordinate falls outside the rectangle.

Reference Data

Range NameMax ValueHexBitsCommon UseResolution on 1920 px
USB HID Absolute655350xFFFF16Touch digitizers, pen tablets0.029 px
Byte Normalized2550xFF8Low-res controllers, MIDI7.53 px
Percentage1000x647CSS / UI layout19.2 px
Per-mille10000x3E810Financial, fine positioning1.92 px
Unity Float1.0 - 64 (f64)Game engines, shaders5.2ร—10โˆ’13 px
12-bit ADC40950xFFF12Resistive touchscreens0.469 px
10-bit ADC10230x3FF10Legacy analog sticks1.877 px
Windows Ink655350xFFFF16Windows pen protocol0.029 px
Android MotionEvent1.0 - 32 (f32)Normalized touch coords1.1ร—10โˆ’4 px
Wacom EMR327670x7FFF15Wacom tablet report0.059 px
24-bit Extended167772150xFFFFFF24High-precision scientific1.1ร—10โˆ’4 px
SVG viewBoxCustom - - Scalable vector graphicsDepends on viewBox

Frequently Asked Questions

The USB HID specification for absolute pointing devices (digitizers, pen tablets) defines coordinate reports as unsigned 16-bit integers, giving a maximum of 65535. Using this range preserves full protocol resolution without floating-point rounding. If your target system expects a different range (e.g., 1.0 for Unity or 255 for MIDI), change the max range parameter accordingly.
The formula yields a value below 0 or above R. This tool applies clamp(r, 0, R) by default, snapping out-of-bounds inputs to the nearest edge. You can disable clamping to see the raw extrapolated value, which is useful for diagnosing misregistered bounds in digitizer firmware.
JavaScript uses IEEE 754 double-precision (64-bit) floats, which provide 15 - 17 significant decimal digits. For a range of 65535 and typical display dimensions (< 10000 px), rounding error is on the order of 10โˆ’12, far below one quantization step. Precision only becomes relevant if you set the range above approximately 253.
Yes. The bounds input takes four values: x0, y0, w, h. The origin offsets x0 and y0 are subtracted before normalization. A bounds of [100, 200, 800, 600] means the rectangle starts at pixel (100, 200) and extends 800 px wide by 600 px tall.
Yes. Switch to Batch mode and enter one coordinate pair per line in the format x, y. All pairs are converted against the same bounds and range, and results are displayed in a downloadable table. This is useful for processing captured touch-event logs or digitizer calibration dumps.
Toggle the direction switch to Inverse. Enter the relative offset values (rx, ry) and the same bounds used for the original conversion. The tool computes p = (r รท R) ร— s &plus; o to return the absolute pixel position.