Frame perfect: Syncing cursor position and app rendering

michalsustr1 pts0 comments

GitHub - michalsustr/egui-cursor · GitHub

/" data-turbo-transient="true" />

Skip to content

Search or jump to...

Search code, repositories, users, issues, pull requests...

-->

Search

Clear

Search syntax tips

Provide feedback

--><br>We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Cancel

Submit feedback

Saved searches

Use saved searches to filter your results more quickly

-->

Name

Query

To see all available qualifiers, see our documentation.

Cancel

Create saved search

Sign in

/;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up

Appearance settings

Resetting focus

You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.

Dismiss alert

{{ message }}

michalsustr

egui-cursor

Public

Notifications<br>You must be signed in to change notification settings

Fork

Star

master

BranchesTags

Go to file

CodeOpen more actions menu

Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit

History<br>5 Commits<br>5 Commits

download_scripts

download_scripts

examples

examples

src

src

.gitignore

.gitignore

Cargo.lock

Cargo.lock

Cargo.toml

Cargo.toml

LICENSE

LICENSE

README.md

README.md

demo.gif

demo.gif

demo.mp4

demo.mp4

download_all_assets.sh

download_all_assets.sh

index.html

index.html

View all files

Repository files navigation

egui-cursor

egui-cursor is a small crate + demo app for drawing themed cursors inside an<br>eframe/egui app, so app visuals and cursor position stay in sync.

Inspired by https://x.com/rsms/status/2067139891264409851 and https://tonsky.me/blog/every-frame-perfect/

Why

On some systems, the OS cursor and app content can appear slightly out of sync<br>in high-speed motion. This crate paints the cursor in egui itself, so cursor and<br>scene are composited on the same path.

Drawbacks . Because the cursor is rendered by your app, you need to keep app render time<br>low. If frame time spikes, cursor responsiveness will also degrade.

Video downsampled to 1 FPS. Original

Assets

Important : this crate does not bundle cursor assets by default. The non-system<br>theme features are optional and intended for setups that provide/generated<br>assets themselves. This is also why this crate is not published on crates.io yet.<br>If you know how to do this well, please let me know in the issues.

Contributions welcome

Contributions are welcome, especially for:

adding new cursor themes,

improving cursor resolution/quality across themes,

support for animated cursors.

Themes

Currently supported:

System (use OS cursor, no custom painting)

Aosp (generated from AOSP vectors, supersampled)

OpenZone* variants:

OpenZoneBlack

OpenZoneBlackSlim

OpenZoneWhite

OpenZoneWhiteSlim

OpenZoneIce

OpenZoneIceSlim

OpenZoneFire

OpenZoneFireSlim

Cargo Features

From Cargo.toml:

cursor-theme-aosp

cursor-theme-openzone

cursor-theme-all (enables both above)

Default features enable no custom themes.

Using in your app

Minimal integration pattern:

Call set_cursor_theme_with_scale(...) when theme/scale changes.

Keep your normal egui cursor icon logic (ctx.set_cursor_icon(...)).

Call paint_cursor(ctx) at the very end of eframe::App::update.

The demo in examples/demo.rs shows this pattern.

Asset Download / Generation

Assets are generated by scripts in download_scripts:

download_scripts/download_openzone.py

download_scripts/download_aosp.py

download_all_assets.sh (runs both)

Run:

bash ./download_all_assets.sh

Script system dependencies

git

xcursorgen

convert (ImageMagick)

python3

Development

Native

cargo run --bin demo --features cursor-theme-all --release

Web (WASM)

trunk serve --port 8000 --release --features cursor-theme-all

About

No description, website, or topics provided.

Resources

Readme

License

MIT license

Uh oh!

There was an error while loading. Please reload this page.

Activity

Stars

star

Watchers

watching

Forks

forks

Report repository

Releases

No releases published

Packages

Uh oh!

There was an error while loading. Please reload this page.

Uh oh!

There was an error while loading. Please reload this page.

Contributors

Uh oh!

There was an error while loading. Please reload this page.

Languages

Python<br>51.0%

Rust<br>46.6%

HTML<br>1.5%

Shell<br>0.9%

You can’t perform that action at this time.

cursor demo egui reload cargo theme

Related Articles