summaryrefslogtreecommitdiff
path: root/libavfilter/vsrc_mandelbrot.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-11-15 19:58:58 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-11-15 20:04:25 +0100
commit8d51cb4fb8c447371a22b09eec04cbd3b9999583 (patch)
treee7bfe5814650b65e31bbbb68e7314ec624228a9d /libavfilter/vsrc_mandelbrot.c
parent6f20921deec135a68f78cb327472ea6cf28644a5 (diff)
mandelbrot: add mincol inner coloring method.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/vsrc_mandelbrot.c')
-rw-r--r--libavfilter/vsrc_mandelbrot.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/libavfilter/vsrc_mandelbrot.c b/libavfilter/vsrc_mandelbrot.c
index 8f3a0d26ab..402ac51ac8 100644
--- a/libavfilter/vsrc_mandelbrot.c
+++ b/libavfilter/vsrc_mandelbrot.c
@@ -44,6 +44,7 @@ enum Inner{
BLACK,
PERIOD,
CONVTIME,
+ MINCOL,
};
typedef struct Point {
@@ -96,6 +97,7 @@ static const AVOption mandelbrot_options[] = {
{"black", "set black mode", 0, AV_OPT_TYPE_CONST, {.dbl=BLACK}, INT_MIN, INT_MAX, 0, "inner" },
{"period", "set period mode", 0, AV_OPT_TYPE_CONST, {.dbl=PERIOD}, INT_MIN, INT_MAX, 0, "inner" },
{"convergence", "show time until convergence", 0, AV_OPT_TYPE_CONST, {.dbl=CONVTIME}, INT_MIN, INT_MAX, 0, "inner" },
+ {"mincol", "color based on point closest to the origin of the cycle", 0, AV_OPT_TYPE_CONST, {.dbl=MINCOL}, INT_MIN, INT_MAX, 0, "inner" },
{NULL},
};
@@ -266,6 +268,17 @@ static void draw_mandelbrot(AVFilterContext *ctx, uint32_t *color, int linesize,
}
}else if(mb->inner==CONVTIME){
c= (i*255/mb->maxiter)*0x010101;
+ } else if(mb->inner==MINCOL){
+ int j;
+ double closest=9999;
+ int closest_index=0;
+ for(j=i-1; j; j--)
+ if(SQR(mb->zyklus[j][0]) + SQR(mb->zyklus[j][1]) < closest){
+ closest= SQR(mb->zyklus[j][0]) + SQR(mb->zyklus[j][1]);
+ closest_index= j;
+ }
+ closest = sqrt(closest);
+ c= lrintf((mb->zyklus[closest_index][0]/closest+1)*127) + lrintf((mb->zyklus[closest_index][1]/closest+1)*127)*256;
}
}
c |= 0xFF000000;