File size: 1,001 Bytes
2409829 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
use crate::document::NodeNetwork;
use crate::graphene_compiler::Compiler;
use crate::proto::ProtoNetwork;
pub fn load_network(document_string: &str) -> NodeNetwork {
let document: serde_json::Value = serde_json::from_str(document_string).expect("Failed to parse document");
let document = (document["network_interface"]["network"].clone()).to_string();
serde_json::from_str::<NodeNetwork>(&document).expect("Failed to parse document")
}
pub fn compile(network: NodeNetwork) -> ProtoNetwork {
let compiler = Compiler {};
compiler.compile_single(network).unwrap()
}
pub fn load_from_name(name: &str) -> NodeNetwork {
let content = std::fs::read(format!("../../demo-artwork/{name}.graphite")).expect("failed to read file");
let content = std::str::from_utf8(&content).unwrap();
load_network(content)
}
pub static DEMO_ART: [&str; 7] = [
"changing-seasons",
"painted-dreams",
"red-dress",
"valley-of-spires",
"isometric-fountain",
"procedural-string-lights",
"parametric-dunescape",
];
|