Skip to content

Commit 7ac30fe

Browse files
authored
Merge pull request #3 from ada-x64/split-crates
Split lib and app into separate crates
2 parents fa24ddd + a18751f commit 7ac30fe

16 files changed

Lines changed: 97 additions & 48 deletions

File tree

Cargo.lock

Lines changed: 16 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,32 @@ version = "0.1.0"
44
authors = ["John Wells <john@attackgoat.com>"]
55
edition = "2021"
66

7+
[workspace]
8+
members = ["crates/*"]
9+
10+
[workspace.dependencies]
11+
serde = { version = "1", features = ["derive"] }
12+
noise = "0.8"
13+
14+
[profile.release]
15+
opt-level = 2 # fast and small wasm
16+
17+
# Optimize all dependencies even in debug builds:
18+
[profile.dev.package."*"]
19+
opt-level = 2
20+
721
[dependencies]
822
crossbeam-channel = "0.5"
923
eframe = { version = "0.30", features = [
1024
"serde",
1125
"persistence",
12-
] }
26+
]}
1327
egui = "0.30"
1428
egui-snarl = { git = "https://github.com/zakarumych/egui-snarl", features = ["serde"], rev = "b17ce7513987729f1ebe62ed03ca60bd74dcbac2" }
1529
log = "0.4"
16-
noise = "0.8"
17-
ordered-float = "4.2"
18-
serde = { version = "1", features = ["derive"] }
30+
noise_expr={path="./crates/noise_expr"}
31+
serde = {workspace = true}
32+
noise={workspace = true}
1933

2034
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
2135
anyhow = "1.0"
@@ -31,10 +45,3 @@ web-sys = "0.3"
3145
anyhow = "1.0"
3246
lazy_static = "1.4"
3347
rand = "0.8"
34-
35-
[profile.release]
36-
opt-level = 2 # fast and small wasm
37-
38-
# Optimize all dependencies even in debug builds:
39-
[profile.dev.package."*"]
40-
opt-level = 2

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ trunk serve --open
6565
Completed noise graphs may be exported (_right-click on any node_). The output file is `.ron` format
6666
and may be deserialized for use in your programs.
6767

68+
_See [`noise_expr`](crates/noise_expr/README.md)_
69+
6870
Once deserialized into an `Expr` instance you may replace any decimal or integer values using their
6971
name and the `Expr::set_f64` and `Expr::set_u32` functions. Note that node names do not have to be
7072
unique and that all nodes sharing the provided name will be updated. The `Expr::noise` function may
@@ -73,5 +75,5 @@ be used to retrieve a Noise-rs `NoiseFn` implementation.
7375
See the example for more details:
7476

7577
```bash
76-
cargo run --example read_file
78+
cargo run --example read_file --package noise_expr
7779
```

crates/noise_expr/Cargo.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = "noise_expr"
3+
version = "0.1.0"
4+
authors = ["John Wells <john@attackgoat.com>"]
5+
edition = "2021"
6+
7+
[dependencies]
8+
noise = {workspace = true}
9+
ordered-float = "4.2"
10+
serde = {workspace = true}
11+
12+
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
13+
anyhow = "1.0"
14+
env_logger = "0.10"
15+
rfd = "0.12"
16+
ron = "0.8"
17+
18+
[target.'cfg(target_arch = "wasm32")'.dependencies]
19+
wasm-bindgen-futures = "0.4"
20+
web-sys = "0.3"

crates/noise_expr/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# `noise_expr`
2+
3+
[![GitHub](https://img.shields.io/badge/github-attackgoat/noise__expr-blue?logo=github)](https://github.com/attackgoat/noise_gui/crates/noise_expr)
4+
[![crates.io](https://img.shields.io/crates/v/noise_expr)](https://crates.io/crates/noise_expr)
5+
[![docs.rs](https://img.shields.io/docsrs/noise_expr)](https://docs.rs/noise_gui/latest/noise_expr/)
6+
[![MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/attackgoat/noise_gui/blob/master/LICENSE-MIT)
7+
[![Apache](https://img.shields.io/badge/license-Apache-blue.svg)](https://github.com/attackgoat/noise_gui/blob/master/LICENSE-APACHE)
8+
9+
---
10+
11+
A graph serialization library for [`noise_gui`](https://github.com/attackgoat/noise_gui).
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Examples
2+
3+
## Read Expression File
4+
5+
```bash
6+
cargo run --example read_file
7+
```
8+
9+
This example reads an exported expression `.ron` file and returns `NoiseFn` implementations with
10+
different variable values. You may export any expression in the desktop app by right-clicking on the
11+
node.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use noise_gui::Expr;
1+
use noise_expr::Expr;
22

33
fn main() {
44
let mut test_expr: Expr = ron::from_str(include_str!("test.ron")).unwrap();

src/expr.rs renamed to crates/noise_expr/src/expr.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,9 +695,10 @@ impl SelectExpr {
695695
}
696696
}
697697

698-
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
698+
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Default)]
699699
pub enum SourceType {
700700
OpenSimplex,
701+
#[default]
701702
Perlin,
702703
PerlinSurflet,
703704
Simplex,
File renamed without changes.

0 commit comments

Comments
 (0)