aboutsummaryrefslogtreecommitdiff
path: root/helper.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-08-27 19:04:34 +0200
committerCharles <sircharlesaze@gmail.com>2019-08-27 19:04:34 +0200
commitce5cf1b60dae81540b2db366b1408a961f771dcc (patch)
tree25de8dc9727deb188f57fe01c2cf7575d5fbb4bc /helper.c
parent7c48d434f0a68ac47ebe1bd66daa2c86842979c7 (diff)
downloadmandelbrot_cpu-ce5cf1b60dae81540b2db366b1408a961f771dcc.tar.gz
mandelbrot_cpu-ce5cf1b60dae81540b2db366b1408a961f771dcc.tar.bz2
mandelbrot_cpu-ce5cf1b60dae81540b2db366b1408a961f771dcc.zip
Set visualization
Loop throught each pixel and color it black if its in the set, white otherwise. This is eavily inspired by the coding train video on the subject. (https://www.youtube.com/watch?v=6z7GQewK-Ks)
Diffstat (limited to 'helper.c')
-rw-r--r--helper.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/helper.c b/helper.c
new file mode 100644
index 0000000..9920c5d
--- /dev/null
+++ b/helper.c
@@ -0,0 +1,10 @@
+#include <math.h>
+#include "header.h"
+
+double map_range(double x, double src_lo, double src_hi, double dest_lo, double dest_hi)
+{
+ double src_len = fabs(src_hi - src_lo);
+ double dest_len = fabs(dest_hi - dest_lo);
+
+ return (x - src_lo) / src_len * dest_len + dest_lo;
+}