cursors / README.md
fgreenlee_sfemu
Add cursor compositing example to README
808a1c6
---
dataset_info:
features:
- name: cursor_type
dtype: string
- name: os
dtype: string
- name: frames
list: image
- name: frame_delay_ms
dtype: int32
- name: hotspot_x
dtype: float32
- name: hotspot_y
dtype: float32
- name: size_px
dtype: int32
- name: variant
dtype: string
splits:
- name: train
num_bytes: 9006656
num_examples: 366
download_size: 8991436
dataset_size: 9006656
configs:
- config_name: default
data_files:
- split: train
path: data/train-*
license: mit
tags:
- cursors
- gui
- synthetic-data
- grounding
---
# Cursors
A dataset of labelled OS cursor images for compositing onto cursor-free screenshots as synthetic training data for GUI grounding models.
**366 rows** across 7 OS/theme sources, covering 31 cursor types.
## Intended use
Given a screenshot with a cursor composited into it, a model is asked:
*"What cursor type is shown in the red box?"*
The `cursor_type` labels are chosen to be **visually distinguishable** — if two themes render a cursor name differently (e.g. one theme draws `move` as a four-way arrow and another as a closed fist), the label reflects what the cursor actually *looks like*, not what the X11 name says.
## Cursor type taxonomy
### Pointers
| cursor_type | Description | Typical appearance |
|---|---|---|
| `arrow` | Default pointer | Angled arrow pointing upper-left |
| `pointer` | Clickable / link | Hand with index finger pointing |
| `text` | Text selection | Vertical I-beam |
| `text_vertical` | Vertical text selection | Horizontal I-beam |
| `crosshair` | Precision select | Thin cross / plus |
### Drag & drop
| cursor_type | Description | Typical appearance |
|---|---|---|
| `grab` | Element is grabbable | Open hand, palm facing out |
| `grabbing` | Actively dragging | Closed / clenched hand |
| `move` | Movable element | Four-way arrow cross |
| `copy` | Drag-copy | Arrow with small **+** badge |
| `alias` | Create shortcut / link | Arrow with curved-arrow badge |
### Resize
| cursor_type | Description | Typical appearance |
|---|---|---|
| `resize_n` | North (up) | Upward arrow |
| `resize_s` | South (down) | Downward arrow |
| `resize_e` | East (right) | Rightward arrow |
| `resize_w` | West (left) | Leftward arrow |
| `resize_ne` | Northeast | Arrow pointing upper-right |
| `resize_nw` | Northwest | Arrow pointing upper-left |
| `resize_se` | Southeast | Arrow pointing lower-right |
| `resize_sw` | Southwest | Arrow pointing lower-left |
| `resize_ew` | Horizontal | Left-right double arrow |
| `resize_ns` | Vertical | Up-down double arrow |
| `resize_nesw` | Diagonal (/ axis) | Double arrow on NE-SW axis |
| `resize_nwse` | Diagonal (\\ axis) | Double arrow on NW-SE axis |
### Status
| cursor_type | Description | Typical appearance |
|---|---|---|
| `wait` | Busy / loading | Spinning circle or hourglass |
| `progress` | Busy but interactive | Arrow with spinner |
### Other
| cursor_type | Description | Typical appearance |
|---|---|---|
| `not_allowed` | Forbidden / no-drop | Circle with diagonal line |
| `help` | Help available | Arrow with **?** badge |
| `context_menu` | Right-click menu | Arrow with menu icon |
| `cell` | Cell / spreadsheet select | Hollow plus / crosshair |
| `zoom_in` | Zoom in | Magnifying glass with **+** |
| `zoom_out` | Zoom out | Magnifying glass with **−** |
| `all_scroll` | Omnidirectional scroll | Four-way arrow cluster |
## Schema
| Field | Type | Description |
|---|---|---|
| `cursor_type` | string | One of the 31 types above |
| `os` | string | Source OS/theme identifier |
| `frames` | list\[image\] | Cursor image(s). Static cursors have 1 frame; animated cursors (wait, progress) have multiple |
| `frame_delay_ms` | int32 | Milliseconds between animation frames (0 for static) |
| `hotspot_x` | float32 | Click-point x position, normalised 0–1 within the image |
| `hotspot_y` | float32 | Click-point y position, normalised 0–1 within the image |
| `size_px` | int32 | Pixel dimensions of the cursor image (square) |
| `variant` | string | Colour variant: `default`, `black`, `white`, `blue`, `red` |
## Sources
| `os` value | Source | Cursor sizes | Variants |
|---|---|---|---|
| `macos` | System cursors (PDF + NSCursor) | 96px rendered | default |
| `linux-adwaita` | Xcursor binaries with hotspot metadata | 96px | default |
| `linux-apple-cursor` | SVG-rendered Apple-style theme | 96px | black, white |
| `linux-bibata` | SVG-rendered Bibata theme | 96px | black, white |
| `linux-google-cursor` | Google Cursor pre-built PNGs | 200px | black, white, blue, red |
| `linux-notwaita` | SVG-rendered Notwaita theme | 96px | black, white |
| `linux-xcursor-pro` | SVG-rendered Xcursor-Pro theme | 96px | black, white |
## Usage
```python
from datasets import load_dataset
ds = load_dataset("Fraser/cursors", split="train")
# Get all arrow cursors
arrows = ds.filter(lambda r: r["cursor_type"] == "arrow")
# Get a specific cursor image
row = ds[0]
cursor_image = row["frames"][0] # PIL Image
hotspot = (row["hotspot_x"], row["hotspot_y"])
```
### Compositing a cursor onto a screenshot
Place a cursor so its hotspot (the click-point) lands at a target pixel position. The cursor is
scaled to a realistic size and alpha-composited without artifacts.
```python
from datasets import load_dataset
from PIL import Image
def composite_cursor(screenshot, cursor_frame, hotspot_x, hotspot_y,
target_x, target_y, cursor_size=32):
"""Place a cursor on a screenshot with the hotspot at (target_x, target_y)."""
canvas = screenshot.convert("RGBA")
cw, ch = cursor_frame.size
scale = cursor_size / max(cw, ch)
new_w, new_h = max(1, round(cw * scale)), max(1, round(ch * scale))
cursor_scaled = cursor_frame.convert("RGBA").resize((new_w, new_h), Image.LANCZOS)
# Offset so the hotspot lands on the target position
paste_x = target_x - round(hotspot_x * new_w)
paste_y = target_y - round(hotspot_y * new_h)
# Crop if the cursor extends past the screenshot edges
sw, sh = canvas.size
src_left = max(0, -paste_x)
src_top = max(0, -paste_y)
src_right = min(new_w, sw - paste_x)
src_bottom = min(new_h, sh - paste_y)
if src_left >= src_right or src_top >= src_bottom:
return screenshot
cropped = cursor_scaled.crop((src_left, src_top, src_right, src_bottom))
canvas.alpha_composite(cropped, (paste_x + src_left, paste_y + src_top))
return canvas.convert(screenshot.mode)
ds = load_dataset("Fraser/cursors", split="train")
# Pick an arrow cursor from the Adwaita theme
row = ds.filter(lambda r: r["cursor_type"] == "arrow" and r["os"] == "linux-adwaita")[0]
screenshot = Image.open("my_screenshot.png")
result = composite_cursor(
screenshot,
row["frames"][0],
row["hotspot_x"], row["hotspot_y"],
target_x=500, target_y=300, # where the arrow tip should point
cursor_size=32, # realistic size for a 1080p screenshot
)
result.save("my_screenshot_with_cursor.png")
```