add new cell types
This commit is contained in:
parent
611d53c453
commit
79cd0a8fe4
3 changed files with 13 additions and 1 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -2744,6 +2744,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"eframe",
|
"eframe",
|
||||||
"petri",
|
"petri",
|
||||||
|
"rand",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -8,3 +8,4 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
petri = { path = "../petri" }
|
petri = { path = "../petri" }
|
||||||
eframe = "0.27.2"
|
eframe = "0.27.2"
|
||||||
|
rand = "0.8.5"
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
use eframe::{
|
use eframe::{
|
||||||
egui::{CentralPanel, Color32, Painter, Pos2, Rect, Sense, SidePanel, Slider, Ui, Vec2},
|
egui::{CentralPanel, Color32, Painter, Pos2, Rect, Sense, SidePanel, Slider, Ui, Vec2},
|
||||||
|
epaint::Hsva,
|
||||||
NativeOptions,
|
NativeOptions,
|
||||||
};
|
};
|
||||||
use petri::{Cell, Chunk, Dish, Rule, RulePattern, CHUNK_SIZE};
|
use petri::{Cell, Chunk, Dish, Rule, RulePattern, CHUNK_SIZE};
|
||||||
|
use rand::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
eframe::run_native(
|
eframe::run_native(
|
||||||
|
@ -53,12 +55,20 @@ impl eframe::App for UScope {
|
||||||
ui.heading("Cells");
|
ui.heading("Cells");
|
||||||
for (i, cell) in self.celltypes.iter_mut().enumerate() {
|
for (i, cell) in self.celltypes.iter_mut().enumerate() {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.set_width(100.);
|
ui.set_width(120.);
|
||||||
ui.radio_value(&mut self.brush.0, i as u16, "");
|
ui.radio_value(&mut self.brush.0, i as u16, "");
|
||||||
ui.text_edit_singleline(&mut cell.name);
|
ui.text_edit_singleline(&mut cell.name);
|
||||||
ui.color_edit_button_srgba(&mut cell.color);
|
ui.color_edit_button_srgba(&mut cell.color);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if ui.button("add cell").clicked() {
|
||||||
|
let h = random::<f32>();
|
||||||
|
let s = random::<f32>() * 0.5 + 0.5;
|
||||||
|
let v = random::<f32>() * 0.5 + 0.5;
|
||||||
|
let color = Hsva::new(h, s, v, 1.).into();
|
||||||
|
let name = format!("cell #{}", self.celltypes.len());
|
||||||
|
self.celltypes.push(CellData { name, color })
|
||||||
|
}
|
||||||
ui.heading("Rules");
|
ui.heading("Rules");
|
||||||
for rule in &mut self.dish.rules {
|
for rule in &mut self.dish.rules {
|
||||||
rule_editor(ui, rule, &self.celltypes);
|
rule_editor(ui, rule, &self.celltypes);
|
||||||
|
|
Loading…
Reference in a new issue