summaryrefslogtreecommitdiff
path: root/source/benoit/benoit/render/paint/ancient.rs
diff options
context:
space:
mode:
Diffstat (limited to 'source/benoit/benoit/render/paint/ancient.rs')
-rw-r--r--source/benoit/benoit/render/paint/ancient.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/source/benoit/benoit/render/paint/ancient.rs b/source/benoit/benoit/render/paint/ancient.rs
new file mode 100644
index 0000000..a2c01eb
--- /dev/null
+++ b/source/benoit/benoit/render/paint/ancient.rs
@@ -0,0 +1,41 @@
+/*
+ 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/>.
+*/
+
+// Palette function from mandelbrotsdl, my first
+// Mandelbrot renderer.
+
+pub fn ancient(factor: f32) -> (f32, f32, f32) {
+ let factor = factor % 1.0;
+
+ let (red, green, blue) = if !factor.is_nan() {
+ let red = 9.0 * (1.0 - factor) * factor * factor * factor;
+ let green = 15.0 * (1.0 - factor) * (1.0 - factor) * factor * factor;
+ let blue = 8.5 * (1.0 - factor) * (1.0 - factor) * (1.0 - factor) * factor;
+
+ (red, green, blue)
+ } else {
+ (0.0, 0.0, 0.0)
+ };
+
+ return (red, green, blue);
+}