mirror of
https://github.com/CrispyPin/julia-fractal-renderer.git
synced 2024-11-23 02:20:27 +01:00
Compare commits
No commits in common. "f4394ad27340cc3d336fa9b88736952bc9848518" and "153d10ba7a2e386fad437b6cd5e04b23601aa425" have entirely different histories.
f4394ad273
...
153d10ba7a
2 changed files with 24 additions and 45 deletions
|
@ -8,7 +8,6 @@ pub struct RenderOptions {
|
||||||
pub width: usize,
|
pub width: usize,
|
||||||
pub height: usize,
|
pub height: usize,
|
||||||
pub unit_width: f64,
|
pub unit_width: f64,
|
||||||
#[serde(alias = "iterations")]
|
|
||||||
pub max_iter: u16,
|
pub max_iter: u16,
|
||||||
pub cx: f64,
|
pub cx: f64,
|
||||||
pub cy: f64,
|
pub cy: f64,
|
||||||
|
|
68
src/main.rs
68
src/main.rs
|
@ -39,25 +39,20 @@ fn main() {
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
struct JuliaGUI {
|
struct JuliaGUI {
|
||||||
color: (u8, u8, u8),
|
color: (u8, u8, u8),
|
||||||
settings: RenderOptions,
|
|
||||||
export_res_power: u8,
|
|
||||||
#[serde(alias = "export_iterations")]
|
|
||||||
export_max_iter: u16,
|
|
||||||
preview_point: bool,
|
|
||||||
#[serde(default = "default_color_presets")]
|
|
||||||
color_presets: Vec<(String, (u8, u8, u8))>,
|
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
preview: Option<TextureHandle>,
|
preview: Option<TextureHandle>,
|
||||||
|
settings: RenderOptions,
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
preview_render_ms: f64,
|
preview_render_ms: f64,
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
export_render_ms: Option<f64>,
|
export_render_ms: Option<f64>,
|
||||||
|
export_res_power: u8,
|
||||||
|
export_max_iter: u16,
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
export_path: PathBuf,
|
export_path: PathBuf,
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
settings_changed: bool,
|
settings_changed: bool,
|
||||||
#[serde(skip)]
|
preview_point: bool,
|
||||||
new_color_preset_name: String,
|
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
render_thread_handle: Option<JoinHandle<()>>,
|
render_thread_handle: Option<JoinHandle<()>>,
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
|
@ -68,17 +63,6 @@ struct JuliaGUI {
|
||||||
waiting: bool,
|
waiting: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_color_presets() -> Vec<(String, (u8, u8, u8))> {
|
|
||||||
vec![
|
|
||||||
("pink".into(), (8, 2, 6)),
|
|
||||||
("blue".into(), (2, 4, 8)),
|
|
||||||
("green".into(), (2, 8, 4)),
|
|
||||||
("salmon".into(), (8, 4, 4)),
|
|
||||||
("purple".into(), (5, 2, 11)),
|
|
||||||
("yellow".into(), (9, 6, 1)),
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
enum RenderJob {
|
enum RenderJob {
|
||||||
Render(PathBuf, RenderOptions, (u8, u8, u8)),
|
Render(PathBuf, RenderOptions, (u8, u8, u8)),
|
||||||
Exit,
|
Exit,
|
||||||
|
@ -88,15 +72,13 @@ impl Default for JuliaGUI {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
color: (12, 5, 10),
|
color: (12, 5, 10),
|
||||||
color_presets: default_color_presets(),
|
|
||||||
new_color_preset_name: String::new(),
|
|
||||||
preview: None,
|
preview: None,
|
||||||
settings: RenderOptions::default(),
|
settings: RenderOptions::default(),
|
||||||
preview_render_ms: 0.0,
|
preview_render_ms: 0.0,
|
||||||
export_render_ms: None,
|
export_render_ms: None,
|
||||||
export_res_power: 3,
|
export_res_power: 3,
|
||||||
export_max_iter: 512,
|
export_max_iter: 512,
|
||||||
export_path: PathBuf::new(),
|
export_path: "".into(),
|
||||||
settings_changed: true,
|
settings_changed: true,
|
||||||
preview_point: false,
|
preview_point: false,
|
||||||
render_thread_handle: None,
|
render_thread_handle: None,
|
||||||
|
@ -255,20 +237,25 @@ impl eframe::App for JuliaGUI {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.label("Colour (RGB)");
|
ui.label("Colour (RGB)");
|
||||||
ui.menu_button("presets", |ui| {
|
ui.menu_button("presets", |ui| {
|
||||||
let mut to_remove = None;
|
if ui.button("pink").clicked() {
|
||||||
for (i, (name, col)) in self.color_presets.iter().enumerate() {
|
self.color = (8, 2, 6);
|
||||||
ui.horizontal(|ui| {
|
self.settings_changed = true;
|
||||||
if ui.button(name).clicked() {
|
|
||||||
self.color = *col;
|
|
||||||
self.settings_changed = true;
|
|
||||||
}
|
|
||||||
if ui.button("x").clicked() {
|
|
||||||
to_remove = Some(i);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if let Some(i) = to_remove {
|
if ui.button("blue").clicked() {
|
||||||
self.color_presets.remove(i);
|
self.color = (2, 4, 8);
|
||||||
|
self.settings_changed = true;
|
||||||
|
}
|
||||||
|
if ui.button("green").clicked() {
|
||||||
|
self.color = (2, 8, 4);
|
||||||
|
self.settings_changed = true;
|
||||||
|
}
|
||||||
|
if ui.button("salmon").clicked() {
|
||||||
|
self.color = (8, 4, 4);
|
||||||
|
self.settings_changed = true;
|
||||||
|
}
|
||||||
|
if ui.button("purple").clicked() {
|
||||||
|
self.color = (5, 2, 11);
|
||||||
|
self.settings_changed = true;
|
||||||
}
|
}
|
||||||
if ui.button("randomise").clicked() {
|
if ui.button("randomise").clicked() {
|
||||||
self.color = (
|
self.color = (
|
||||||
|
@ -278,13 +265,6 @@ impl eframe::App for JuliaGUI {
|
||||||
);
|
);
|
||||||
self.settings_changed = true;
|
self.settings_changed = true;
|
||||||
}
|
}
|
||||||
ui.horizontal(|ui| {
|
|
||||||
ui.text_edit_singleline(&mut self.new_color_preset_name);
|
|
||||||
if ui.button("add").clicked() {
|
|
||||||
self.color_presets
|
|
||||||
.push((self.new_color_preset_name.clone(), self.color));
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
let set_red = ui.add(Slider::new(&mut self.color.0, 0..=16));
|
let set_red = ui.add(Slider::new(&mut self.color.0, 0..=16));
|
||||||
|
@ -408,10 +388,10 @@ impl eframe::App for JuliaGUI {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_exit(&mut self, _gl: Option<&eframe::glow::Context>) {
|
fn on_exit(&mut self, _gl: Option<&eframe::glow::Context>) {
|
||||||
self.save_settings();
|
|
||||||
if let Some(channel) = &self.render_thread {
|
if let Some(channel) = &self.render_thread {
|
||||||
channel.send(RenderJob::Exit).unwrap();
|
channel.send(RenderJob::Exit).unwrap();
|
||||||
}
|
}
|
||||||
self.render_thread_handle.take().unwrap().join().unwrap();
|
self.render_thread_handle.take().unwrap().join().unwrap();
|
||||||
|
self.save_settings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue