Skip to content

Commit

Permalink
Reorganize demos into subfolder (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter authored Jun 6, 2024
1 parent 0cf551f commit 7e33453
Show file tree
Hide file tree
Showing 34 changed files with 114 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/constraints-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./constraints
working-directory: ./demos/constraints
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/wasm-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./wasm-demo
working-directory: ./demos/web-editor
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Install wasm target
run: rustup target add wasm32-unknown-unknown
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
run: |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Install npm dependencies
run: npm install
- name: Check Prettier
Expand Down
62 changes: 31 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
resolver = "2"
members = [
"fidget",
"constraints",
"demo",
"viewer",
"demos/constraints",
"demos/cli",
"demos/viewer",
"workspace-hack",
]
exclude = ["wasm-demo"]
exclude = ["demos/web-editor"]

[profile.release]
debug = true
Expand Down
29 changes: 4 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,31 +51,10 @@ Issues and PRs are welcome, although I'm unlikely to merge anything which adds
substantial maintenance burden. This is a personal-scale experimental project,
so adjust your expectations accordingly.

## Demo applications
In the [repository on Github](https://github.com/mkeeter/fidget), there are
two demo applications:

- `demo` does bitmap rendering and meshing from the command line
- `viewer` is a minimal GUI for interactive exploration

These are deliberately not published to [https://crates.io](crates.io), because
they're demo applications and not complete end-user tools.

## WebAssembly demo
The `wasm-demo` subfolder embeds Fidget into a web application. Building this
demo requires [`wasm-pack`](https://rustwasm.github.io/wasm-pack/)
to be installed on the host system.

In that folder, run it with
```
npm install
npm run serve
```

Or bundle files for distribution with
```
npm run build
```
## Demos
The [`demos` folder](demos/README.md) contains several demo tools and
applications built using the Fidget crate,
ranging from CLI to GUI to web app.

## Support matrix
At the moment, Fidget supports a limited number of platforms:
Expand Down
1 change: 1 addition & 0 deletions demos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!*/screenshot.png
41 changes: 41 additions & 0 deletions demos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Fidget demos
## Command-line demo ([`cli`](cli/))

Bitmap rendering and meshing from the command line
```shell
$ cargo run -pfidget-cli --release -- -i models/prospero.vm render2d -s512 --eval=vm -oout.png
Finished release [optimized + debuginfo] target(s) in 0.07s
Running `target/release/fidget-cli -i models/prospero.vm render2d -s512 --eval=vm -oout.png`
[2024-06-06T16:08:12Z INFO fidget_cli] Loaded file in 4.528208ms
[2024-06-06T16:08:12Z INFO fidget_cli] Built shape in 2.375208ms
[2024-06-06T16:08:12Z INFO fidget_cli] Rendered 1x at 14.489 ms/frame
```

## Script viewer ([`viewer`](viewer/))
Minimal desktop GUI for interactive exploration,
using [`egui`](https://github.com/emilk/egui)

```shell
cargo run --release -pfidget-viewer
```

![screenshot of script viewer](viewer/screenshot.png)

## Constraint solving ([`constraints`](constraints/))
Example of using Fidget for constraint solving.
Uses [`egui`](https://github.com/emilk/egui)
and runs either on the desktop or as a web app.
```shell
cargo run --release -pconstraints
```

![screenshot of contraint editor](constraints/screenshot.png)

See the [subfolder](constraints/) for details on bundling for the web.

## Web-based editor ([`web-editor`](web-editor/))
Integrates Fidget into a TypeScript project (web only)

![screenshot of web editor](web-editor/screenshot.png)

See the [subfolder](web-editor/) for details on bundling for the web.
6 changes: 3 additions & 3 deletions demo/Cargo.toml → demos/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[package]
name = "demo"
name = "fidget-cli"
version = "0.1.0"
edition = "2021"

[dependencies]
fidget = { path = "../fidget", default-features = false, features = ["render", "mesh"] }
fidget = { path = "../../fidget", default-features = false, features = ["render", "mesh"] }

anyhow = "1"
clap = { version = "4", features = ["derive"] }
env_logger = "0.11.2"
image = { version = "0.24", default-features = false, features = ["png"] }
log = "0.4"
nalgebra = "0.31"
workspace-hack = { version = "0.1", path = "../workspace-hack" }
workspace-hack = { version = "0.1", path = "../../workspace-hack" }

[features]
jit = ["fidget/jit"]
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions constraints/Cargo.toml → demos/constraints/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ eframe = { version = "0.27", default-features = false, features = [
"glow", # Use the glow rendering backend. Alternative: "wgpu".
] }

fidget = { path = "../fidget", default-features = false, features = ["solver"] }
fidget = { path = "../../fidget", default-features = false, features = ["solver"] }
log = "0.4"
workspace-hack = { version = "0.1", path = "../workspace-hack" }
workspace-hack = { version = "0.1", path = "../../workspace-hack" }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
env_logger = "0.10.0"
Expand Down
3 changes: 2 additions & 1 deletion constraints/README.md → demos/constraints/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Demo of constraint solving
## WebAssembly
### Setup
Install the [`trunk`](https://trunkrs.dev/) bundler with
```
cargon install +locked trunk # installs the `trunk` bundler
cargo install +locked trunk
```
### Developing
In this folder, run
Expand Down
File renamed without changes.
Binary file added demos/constraints/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
6 changes: 3 additions & 3 deletions viewer/Cargo.toml → demos/viewer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "viewer"
name = "fidget-viewer"
version = "0.1.0"
edition = "2021"

Expand All @@ -15,12 +15,12 @@ eframe = { version = "0.27", default-features = false, features = [
] }
env_logger = "0.10.0"

fidget = { path = "../fidget", default-features = false, features = ["render", "rhai"] }
fidget = { path = "../../fidget", default-features = false, features = ["render", "rhai"] }
log = "0.4"
nalgebra = "0.31"
notify = "5.0"
rhai = "1.10"
workspace-hack = { version = "0.1", path = "../workspace-hack" }
workspace-hack = { version = "0.1", path = "../../workspace-hack" }

[features]
default = ["jit"]
Expand Down
Binary file added demos/viewer/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion wasm-demo/Cargo.toml → demos/web-editor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ crate-type = ["cdylib"]

[dependencies]
bincode = "1.3.3"
fidget = {path = "../fidget", default-features = false, features = ["rhai", "mesh", "render"]}
fidget = {path = "../../fidget", default-features = false, features = ["rhai", "mesh", "render"]}
wasm-bindgen = "0.2.92"
nalgebra = "0.31"

Expand Down
17 changes: 17 additions & 0 deletions demos/web-editor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
The `web-editor` subfolder embeds Fidget into a web application.

Building this demo requires [`wasm-pack`](https://rustwasm.github.io/wasm-pack/)
to be installed on the host system.

Run the editor demo with

```
npm install
npm run serve
```

Or bundle files for distribution with

```
npm run build
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added demos/web-editor/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion fidget/src/rhai/core.rhai
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn intersection(a, b) {
}

fn inverse(a) {
a.neg()
-a
}

fn difference(a, b) {
Expand Down

0 comments on commit 7e33453

Please sign in to comment.