Maps screen touch coordinates to grid cells; computes distances/clamps for UI input in game geometry.
// Source: https://github.com/SweetSophia/openclaw-pixel-agents | License: MIT | Copyright 2026 Sherina
// Provided via justclaw.it.com; keep this notice with the code.
export interface ClientPoint {
clientX: number;
clientY: number;
}
export interface ScreenRect {
readonly left: number;
readonly top: number;
readonly width: number;
readonly height: number;
}
export interface CanvasMetrics {
readonly rect: ScreenRect;
readonly canvasWidth: number;
readonly canvasHeight: number;
readonly tileSize: number;
}
export interface GridPoint {
gridX: number;
gridY: number;
}
/** Map client coordinates into the canvas grid, accounting for object-fit bars. */
// `Readonly<CanvasMetrics>` widens the readonly view structurally โ consumed
// as a guarantee that no consumer ca
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key