summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md8
-rw-r--r--Cargo.toml4
-rw-r--r--source/benoit/benoit.rs4
-rw-r--r--source/benoit/benoit/colour_data.rs3
-rw-r--r--source/benoit/benoit/configuration/load.rs4
-rw-r--r--source/benoit/benoit/palette.rs14
-rw-r--r--source/benoit/benoit/palette/data.rs28
-rw-r--r--source/benoit/benoit/palette/paint.rs8
-rw-r--r--source/benoit/benoit/palette/paint/emerald.rs34
-rw-r--r--source/benoit/benoit/palette/paint/ruby.rs34
-rw-r--r--source/benoit/benoit/palette/paint/twilight.rs (renamed from source/benoit/benoit/palette/paint/ancient.rs)2
-rw-r--r--source/benoit/benoit/render_data.rs3
-rw-r--r--source/benoit/main.rs2
13 files changed, 122 insertions, 26 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 99e632d..57a700a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,11 @@
+# 2.5.0
+
+* Make fill_palettes safe
+* Rename 'ancient' palette to 'twilight'
+* Update package description
+* Add new palettes 'emerald' and 'ruby'
+* Bump minor version
+
# 2.4.1
* Remove renderers in favour of the fractal type
diff --git a/Cargo.toml b/Cargo.toml
index fbe0085..2a9d20a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,9 +1,9 @@
[package]
name = "benoit"
-version = "2.4.1"
+version = "2.5.0"
authors = ["Gabriel Bjørnager Jensen"]
edition = "2021"
-description = "Mandelbrot renderer."
+description = "Multithreaded Mandelbrot renderer with support for PNG and WebP encoding."
readme = "README.md"
repository = "https://mandelbrot.dk/benoit"
diff --git a/source/benoit/benoit.rs b/source/benoit/benoit.rs
index 7d3a165..1e70ff8 100644
--- a/source/benoit/benoit.rs
+++ b/source/benoit/benoit.rs
@@ -35,8 +35,8 @@ pub mod video;
pub const VERSION: (u32, u32, u32) = (
0x2, // Major
- 0x4, // Minor
- 0x1, // Patch
+ 0x5, // Minor
+ 0x0, // Patch
);
pub const PRECISION: u32 = 0x80;
diff --git a/source/benoit/benoit/colour_data.rs b/source/benoit/benoit/colour_data.rs
index 4ea3852..4f8dac4 100644
--- a/source/benoit/benoit/colour_data.rs
+++ b/source/benoit/benoit/colour_data.rs
@@ -71,6 +71,3 @@ impl ColourData {
return (self.exponent, self.max_iter_count, self.colour_range, self.palette_data);
}
}
-
-unsafe impl Send for ColourData {}
-unsafe impl Sync for ColourData {}
diff --git a/source/benoit/benoit/configuration/load.rs b/source/benoit/benoit/configuration/load.rs
index c03e299..f17c145 100644
--- a/source/benoit/benoit/configuration/load.rs
+++ b/source/benoit/benoit/configuration/load.rs
@@ -83,12 +83,14 @@ impl Configuration {
if let Some(name) = get_string(&configuration_table, "palette") {
configuration.palette = match name.as_str() {
- "ancient" => Palette::Ancient,
+ "emerald" => Palette::Emerald,
"fire" => Palette::Fire,
"greyscale" => Palette::Greyscale,
"hsv" => Palette::Hsv,
"lch" => Palette::Lch,
+ "ruby" => Palette::Ruby,
"sapphire" => Palette::Sapphire,
+ "twilight" => Palette::Twilight,
name => panic!("invalid palette \"{name}\""),
};
}
diff --git a/source/benoit/benoit/palette.rs b/source/benoit/benoit/palette.rs
index c5157f6..f47b4fb 100644
--- a/source/benoit/benoit/palette.rs
+++ b/source/benoit/benoit/palette.rs
@@ -38,27 +38,31 @@ pub type PaletteData = [(f32, f32, f32); PALETTE_DATA_LENGTH];
#[repr(u8)]
pub enum Palette {
// Sorted according to date of addition.
- Ancient,
+ Twilight,
Fire,
Greyscale,
+ Ruby,
+ Emerald,
Sapphire,
Hsv,
Lch,
}
impl Palette {
- const MIN: Self = Palette::Ancient;
+ const MIN: Self = Palette::Twilight;
const MAX: Self = Palette::Lch;
#[must_use]
pub fn name(self) -> &'static str {
return match self {
- Palette::Ancient => "ancient",
+ Palette::Emerald => "emerald",
Palette::Fire => "fire",
Palette::Greyscale => "greyscale",
Palette::Hsv => "hsv",
Palette::Lch => "lch",
+ Palette::Ruby => "ruby",
Palette::Sapphire => "sapphire",
+ Palette::Twilight => "twilight",
};
}
@@ -86,12 +90,14 @@ impl Palette {
#[must_use]
fn function(self) -> fn(f32) -> (f32, f32, f32) {
return match self {
- Palette::Ancient => paint::ancient,
+ Palette::Emerald => paint::emerald,
Palette::Fire => paint::fire,
Palette::Greyscale => paint::greyscale,
Palette::Hsv => paint::hsv,
Palette::Lch => paint::lch,
+ Palette::Ruby => paint::ruby,
Palette::Sapphire => paint::sapphire,
+ Palette::Twilight => paint::twilight,
};
}
}
diff --git a/source/benoit/benoit/palette/data.rs b/source/benoit/benoit/palette/data.rs
index 28bfba4..cd5d866 100644
--- a/source/benoit/benoit/palette/data.rs
+++ b/source/benoit/benoit/palette/data.rs
@@ -23,35 +23,49 @@
use crate::benoit::palette::{Palette, PALETTE_DATA_LENGTH, PaletteData};
+extern crate enum_iterator;
+
use enum_iterator::all;
+use std::sync::atomic::{AtomicBool, Ordering};
+use std::time::Instant;
impl Palette {
#[must_use]
pub(super) unsafe fn mut_data(self) -> &'static mut PaletteData {
- return unsafe { match self {
- Palette::Ancient => &mut DATA_ANCIENT,
+ return match self {
+ Palette::Emerald => &mut DATA_EMERALD,
Palette::Fire => &mut DATA_FIRE,
Palette::Greyscale => &mut DATA_GREYSCALE,
Palette::Hsv => &mut DATA_HSV,
Palette::Lch => &mut DATA_LCH,
+ Palette::Ruby => &mut DATA_RUBY,
Palette::Sapphire => &mut DATA_SAPPHIRE,
- } };
+ Palette::Twilight => &mut DATA_TWILIGHT,
+ };
}
}
+#[must_use]
const fn default_palette_data() -> PaletteData {
return [(0.0, 0.0, 0.0); PALETTE_DATA_LENGTH];
}
-static mut DATA_ANCIENT: PaletteData = default_palette_data();
+static mut DATA_EMERALD: PaletteData = default_palette_data();
static mut DATA_FIRE: PaletteData = default_palette_data();
static mut DATA_GREYSCALE: PaletteData = default_palette_data();
static mut DATA_HSV: PaletteData = default_palette_data();
static mut DATA_LCH: PaletteData = default_palette_data();
+static mut DATA_RUBY: PaletteData = default_palette_data();
static mut DATA_SAPPHIRE: PaletteData = default_palette_data();
+static mut DATA_TWILIGHT: PaletteData = default_palette_data();
+
+static PALETTES_FILLED: AtomicBool = AtomicBool::new(false);
-pub unsafe fn fill_palettes() {
- use std::time::Instant;
+pub fn fill_palettes() {
+ match PALETTES_FILLED.compare_exchange(false, true, Ordering::Relaxed, Ordering::Relaxed) {
+ Err(_) => panic!("palettes already filled"),
+ _ => {},
+ };
// We would like to precalculate the palettes at
// compile-time, but Rust does not allow
@@ -61,7 +75,7 @@ pub unsafe fn fill_palettes() {
let time = Instant::now();
for palette in all::<Palette>() {
- let data = palette.mut_data();
+ let data = unsafe { palette.mut_data() };
let function = palette.function();
for index in 0x0..PALETTE_DATA_LENGTH {
diff --git a/source/benoit/benoit/palette/paint.rs b/source/benoit/benoit/palette/paint.rs
index ff3bd47..4859c28 100644
--- a/source/benoit/benoit/palette/paint.rs
+++ b/source/benoit/benoit/palette/paint.rs
@@ -21,16 +21,20 @@
If not, see <https://www.gnu.org/licenses/>.
*/
-pub mod ancient;
+pub mod emerald;
pub mod fire;
pub mod greyscale;
pub mod hsv;
pub mod lch;
+pub mod ruby;
pub mod sapphire;
+pub mod twilight;
-pub use ancient::*;
+pub use emerald::*;
pub use fire::*;
pub use greyscale::*;
pub use hsv::*;
pub use lch::*;
+pub use ruby::*;
pub use sapphire::*;
+pub use twilight::*;
diff --git a/source/benoit/benoit/palette/paint/emerald.rs b/source/benoit/benoit/palette/paint/emerald.rs
new file mode 100644
index 0000000..7244e6a
--- /dev/null
+++ b/source/benoit/benoit/palette/paint/emerald.rs
@@ -0,0 +1,34 @@
+/*
+ Copyright 2021, 2023 Gabriel Bjørnager Jensen.
+
+ This file is part of Benoit.
+
+ Benoit is free software: you can redistribute it
+ and/or modify it under the terms of the GNU
+ Affero General Public License as published by
+ the Free Software Foundation, either version 3
+ of the License, or (at your option) any later
+ version.
+
+ Benoit is distributed in the hope that it will
+ be useful, but WITHOUT ANY WARRANTY; without
+ even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU
+ Affero General Public License along with Benoit.
+ If not, see <https://www.gnu.org/licenses/>.
+*/
+
+pub fn emerald(factor: f32) -> (f32, f32, f32) {
+ let factor = factor % 1.0;
+
+ let factor = (if factor >= 1.0 / 2.0 {
+ 1.0 - factor
+ } else {
+ factor
+ }) * 2.0;
+
+ return (factor * factor, factor, factor * factor * factor);
+}
diff --git a/source/benoit/benoit/palette/paint/ruby.rs b/source/benoit/benoit/palette/paint/ruby.rs
new file mode 100644
index 0000000..8f23a3e
--- /dev/null
+++ b/source/benoit/benoit/palette/paint/ruby.rs
@@ -0,0 +1,34 @@
+/*
+ Copyright 2021, 2023 Gabriel Bjørnager Jensen.
+
+ This file is part of Benoit.
+
+ Benoit is free software: you can redistribute it
+ and/or modify it under the terms of the GNU
+ Affero General Public License as published by
+ the Free Software Foundation, either version 3
+ of the License, or (at your option) any later
+ version.
+
+ Benoit is distributed in the hope that it will
+ be useful, but WITHOUT ANY WARRANTY; without
+ even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU
+ Affero General Public License along with Benoit.
+ If not, see <https://www.gnu.org/licenses/>.
+*/
+
+pub fn ruby(factor: f32) -> (f32, f32, f32) {
+ let factor = factor % 1.0;
+
+ let factor = (if factor >= 1.0 / 2.0 {
+ 1.0 - factor
+ } else {
+ factor
+ }) * 2.0;
+
+ return (factor, factor * factor * factor, factor * factor);
+}
diff --git a/source/benoit/benoit/palette/paint/ancient.rs b/source/benoit/benoit/palette/paint/twilight.rs
index cd11e1a..79931ae 100644
--- a/source/benoit/benoit/palette/paint/ancient.rs
+++ b/source/benoit/benoit/palette/paint/twilight.rs
@@ -24,7 +24,7 @@
// Palette function from mandelbrotsdl, my first
// Mandelbrot renderer.
-pub fn ancient(factor: f32) -> (f32, f32, f32) {
+pub fn twilight(factor: f32) -> (f32, f32, f32) {
let factor = factor % 1.0;
let red = 9.0 * (1.0 - factor) * factor * factor * factor;
diff --git a/source/benoit/benoit/render_data.rs b/source/benoit/benoit/render_data.rs
index 4f6eaa9..f846c0c 100644
--- a/source/benoit/benoit/render_data.rs
+++ b/source/benoit/benoit/render_data.rs
@@ -144,6 +144,3 @@ impl RenderData {
return z;
}
}
-
-unsafe impl Send for RenderData {}
-unsafe impl Sync for RenderData {}
diff --git a/source/benoit/main.rs b/source/benoit/main.rs
index 4263ff4..adc1617 100644
--- a/source/benoit/main.rs
+++ b/source/benoit/main.rs
@@ -44,7 +44,7 @@ fn main() {
println!("Le p\u{E8}re cogita et c'est pourquoi il fut.");
println!();
- unsafe { fill_palettes() };
+ fill_palettes();
let mut arguments = args();