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 build
orcargo build --release
- Run
cargo run
orcargo 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
wasm32
compiler 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
debug
ortrace
level, so reflect upon any value you may have set for theRUST_LOG
environment variable.echo $RUST_LOG
- Build
trunk build --release
- Build, as described above.
- Serve the build results over
http
on127.0.0.1:8080
at 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#dev
in a web browser.- Note: The
assets/sw.js
script 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#dev
toindex.html
will skip this caching, allowing us to load the latest builds during development.
- Note: The
- Build, as described above.
- Upload the resulting
dist
directory 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-pages
branch with the top-levelindex.html
in either/
(root) ordocs
. - Go to Repository -> Settings -> Pages -> Source -> set to
gh-pages
branch 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.toml
The workspacesunangle/
Thesunangle
packageCargo.toml
src/
lib.rs
Defines module structure, re-exportsSunangleApp
.main.rs
Program startup,fn main()
ui/
Egui-based uithreed/
three_d based viewegui_app.rs
The main application struct,SunangleApp
.- Implements the
eframe::App
trait.- Local save state logic
- "Updates" the UI on every redraw
- Implements the
tai.rs
Type representing International Atomic Time, TAIworld_state.rs
A representation of the world, computed from a point in timeview_state.rs
A representation of the view, camera position, etc.time/
Some old code for time, mostly usingchrono
instead
Trunk.toml
Configurestrunk
build system for WASMwww/
index.html
Main web page, but also controlstrunk
buildassets/
used in building the web app
rust-toolchain
Specifies 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
egui
andeframe
it is recommended you do so one version at the time, and read about the changes in the egui changelog and eframe changelog.