1 /* 2 flame - cosmic recursive fractal flames 3 Copyright (C) 1992 Scott Draves <spot@cs.cmu.edu> 4 5 This program is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <https://www.gnu.org/licenses/>. 17 */ 18 19 20 #ifndef libifs_included 21 #define libifs_included 22 23 #include <stdlib.h> 24 #include <stdio.h> 25 #include <math.h> 26 27 #include "cmap.h" 28 29 #define EPS (1e-10) 30 31 #define variation_random (-1) 32 33 #define NVARS 29 34 #define NXFORMS 6 35 36 typedef double point[3]; 37 38 typedef struct { 39 double var[NVARS]; /* normalized interp coefs between variations */ 40 double c[3][2]; /* the coefs to the affine part of the function */ 41 double density; /* prob is this function is chosen. 0 - 1 */ 42 double color; /* color coord for this function. 0 - 1 */ 43 } xform; 44 45 typedef struct { 46 xform xform[NXFORMS]; 47 clrmap cmap; 48 double time; 49 int cmap_index; 50 double brightness; /* 1.0 = normal */ 51 double contrast; /* 1.0 = normal */ 52 double gamma; 53 int width, height; /* of the final image */ 54 int spatial_oversample; 55 double center[2]; /* camera center */ 56 double zoom; /* effects ppu and sample density */ 57 double pixels_per_unit; /* and scale */ 58 double spatial_filter_radius; /* variance of gaussian */ 59 double sample_density; /* samples per pixel (not bucket) */ 60 /* in order to motion blur more accurately we compute the logs of the 61 sample density many times and average the results. we interpolate 62 only this many times. */ 63 int nbatches; 64 /* this much color resolution. but making it too high induces clipping */ 65 int white_level; 66 int cmap_inter; /* if this is true, then color map interpolates one entry 67 at a time with a bright edge */ 68 double pulse[2][2]; /* [i][0]=magnitude [i][1]=frequency */ 69 double wiggle[2][2]; /* frequency is /minute, assuming 30 frames/s */ 70 } control_point; 71 72 73 74 extern void iterate(control_point *cp, int n, int fuse, point points[]); 75 extern void interpolate(control_point cps[], int ncps, double time, control_point *result); 76 extern void tokenize(char **ss, char *argv[], int *argc); 77 extern void print_control_point(FILE *f, control_point *cp, int quote); 78 extern void random_control_point(control_point *cp, int ivar); 79 extern void parse_control_point(char **ss, control_point *cp); 80 extern void estimate_bounding_box(control_point *cp, double eps, double *bmin, double *bmax); 81 extern double standard_metric(control_point *cp1, control_point *cp2); 82 extern double random_uniform01(void); 83 extern double random_uniform11(void); 84 extern double random_gaussian(void); 85 extern void mult_matrix(double s1[2][2], double s2[2][2], double d[2][2]); 86 void copy_variation(control_point *cp0, control_point *cp1); 87 #endif 88