One can take measurements of the angle of the Sun from various locations times at various times. This is an app to visualize the resulting geometry.
You can test the sunangle app at https://marshray.github.io/sunangle/.
This app is grateful to the egui project authors and their generosity for the
template repo for eframe,
a framework for writing apps using awesome egui UI,
a simple and straightforward way to get started writing a GUI app in Rust.
You can build it natively and run it on your local system, or build it for the web and share it using Github Pages.
Make sure you are using the latest version of stable rust by running rustup update.
On Linux you need to first run:
sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev
On Fedora Rawhide you need to run:
dnf install clang clang-devel clang-tools-extra libxkbcommon-devel pkg-config openssl-devel libxcb-devel gtk3-devel atk fontconfig-devel
From the top of your checkout (the directory containing this README.md):
- Clean
cargo clean; cargo clean --release - Run
cargo buildorcargo build --release
- Run
cargo runorcargo run --release
Then to run the app
cargo run --release
Build, test locally, and deploy as a WASM web app
Trunk is used to build for the web.
- Install the
wasm32compiler targetrustup target add wasm32-unknown-unknown - Install Trunk
cargo install --locked trunk
From the top of your checkout (the directory containing this README.md):
- Clean
trunk clean - Some of the build steps are extremely verbose at
debugortracelevel, so reflect upon any value you may have set for theRUST_LOGenvironment variable.echo $RUST_LOG - Build
trunk build --release
- Build, as described above.
- Serve the build results over
httpon127.0.0.1:8080at the path/sunangle:trunk serve --release- Note: Trunk will watch for changes to project files and rebuild automatically.
- Navigate to
http://127.0.0.1:8080/sunangle/index.html#devin a web browser.- Note: The
assets/sw.jsscript will try to cache our app, and will load the cached version when it cannot connect to server, allowing your app to work offline (like PWA). Appending#devtoindex.htmlwill skip this caching, allowing us to load the latest builds during development.
- Note: The
- Build, as described above.
- Upload the resulting
distdirectory to your website such that it is served at/sunangle/path.
- GitHub Pages is a free option used by many projects already using GitHub.
- Ensure you have a
gh-pagesbranch with the top-levelindex.htmlin either/(root) ordocs. - Go to Repository -> Settings -> Pages -> Source -> set to
gh-pagesbranch and/(root) ordocs.
- There is a workflow that you can enable to auto-deploy the app to GitHub pages.
- Ensure you have a
sunangle/Cargo.tomlThe workspacesunangle/ThesunanglepackageCargo.tomlsrc/lib.rsDefines module structure, re-exportsSunangleApp.main.rsProgram startup,fn main()ui/Egui-based uithreed/three_d based viewegui_app.rsThe main application struct,SunangleApp.- Implements the
eframe::Apptrait.- Local save state logic
- "Updates" the UI on every redraw
- Implements the
tai.rsType representing International Atomic Time, TAIworld_state.rsA representation of the world, computed from a point in timeview_state.rsA representation of the view, camera position, etc.time/Some old code for time, mostly usingchronoinstead
Trunk.tomlConfigurestrunkbuild system for WASMwww/index.htmlMain web page, but also controlstrunkbuildassets/used in building the web app
rust-toolchainSpecifies what components are needed fromrustup
Official egui docs: https://docs.rs/egui
A video introduction: Getting started with Rust 🦀 2021: 7a. Building a GUI app in Rust [Part A]
For inspiration, check out the the egui web demo and follow the links to its source code.
As of 2023, egui is in active development with frequent releases with breaking changes.
- eframe_template will be updated in lock-step to always use the latest version of egui.
- When updating
eguiandeframeit is recommended you do so one version at the time, and read about the changes in the egui changelog and eframe changelog.