| 1 | /* |
| 2 | FLAM3 - cosmic recursive fractal flames |
| 3 | Copyright (C) 1992-2009 Spotworks LLC |
| 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 <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #include "private.h"cxx . . $ `<file>/private.h`/ |
| 20 | |
| 21 | |
| 22 | #define MAXARGScxx . . $ `flam3-convert.c:22:9`! 1000 |
| 23 | #define streqlcxx . . $ `flam3-convert.c:23:9`!(x,y) (!strcmp(x,y)) |
| 24 | |
| 25 | |
| 26 | /* |
| 27 | * split a string passed in ss into tokens on whitespace. |
| 28 | * # comments to end of line. ; terminates the record |
| 29 | */ |
| 30 | void tokenizecxx . . $ tokenize(29c5cb4808ce8941).(ss, argv, argc) |
| 31 | char **ss; |
| 32 | char *argv[]; |
| 33 | int *argc; |
| 34 | { |
| 35 | char *s = *ss; |
| 36 | int i = 0, state = 0; |
| 37 | |
| 38 | while (*s != ';') { |
| 39 | char c = *s; |
| 40 | switch (state) { |
| 41 | case 0: |
| 42 | if ('#' == c) |
| 43 | state = 2; |
| 44 | else if (!isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(c)) { |
| 45 | argv[i] = s; |
| 46 | i++; |
| 47 | state = 1; |
| 48 | } |
| 49 | case 1: |
| 50 | if (isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(c)) { |
| 51 | *s = 0; |
| 52 | state = 0; |
| 53 | } |
| 54 | case 2: |
| 55 | if ('\n' == c) |
| 56 | state = 0; |
| 57 | } |
| 58 | s++; |
| 59 | } |
| 60 | *s = 0; |
| 61 | *ss = s+1; |
| 62 | *argc = i; |
| 63 | } |
| 64 | |
| 65 | /* |
| 66 | * given a pointer to a string SS, fill fields of a control point CP. |
| 67 | * return a pointer to the first unused char in SS. totally barfucious, |
| 68 | * must integrate with tcl soon... |
| 69 | */ |
| 70 | |
| 71 | void parse_control_point_oldcxx . . $ parse_control_point_old(72567ccc91e2a81a).(char **ss, flam3_genomecxx . . $ flam3_genome# *cp) { |
| 72 | char *argv[MAXARGScxx . . $ `flam3-convert.c:22:9`!]; |
| 73 | int argc, i, j; |
| 74 | int set_cm = 0, set_image_size = 0, set_nbatches = 0, set_white_level = 0; |
| 75 | int set_spatial_oversample = 0, set_hr = 0; |
| 76 | double *slot = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, xf, cm, t, nbatches, white_level, spatial_oversample, cmap_inter; |
| 77 | double image_size[2]; |
| 78 | |
| 79 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(cp, 0, sizeof(flam3_genomecxx . . $ flam3_genome#)); |
| 80 | |
| 81 | flam3_add_xformscxx . . $ flam3_add_xforms(62aa529b45550848).(cp, flam3_nxformscxx . . $ `flam3.h:72:9`!, 0, 0); |
| 82 | |
| 83 | for (i = 0; i < flam3_nxformscxx . . $ `flam3.h:72:9`!; i++) { |
| 84 | cp->xformcxx . . $ $anonymous_type_d4ed57c78da46593_3#xform.[i].densitycxx . . $ xform#density. = 0.0; |
| 85 | cp->xformcxx . . $ $anonymous_type_d4ed57c78da46593_3#xform.[i].colorcxx . . $ xform#color. = i&1; |
| 86 | cp->xformcxx . . $ $anonymous_type_d4ed57c78da46593_3#xform.[i].color_speedcxx . . $ xform#color_speed. = 0.5; |
| 87 | cp->xformcxx . . $ $anonymous_type_d4ed57c78da46593_3#xform.[i].animatecxx . . $ xform#animate. = 1.0; |
| 88 | cp->xformcxx . . $ $anonymous_type_d4ed57c78da46593_3#xform.[i].varcxx . . $ xform#var.[0] = 1.0; |
| 89 | for (j = 1; j < flam3_nvariationscxx . . $ `flam3.h:71:9`!; j++) |
| 90 | cp->xformcxx . . $ $anonymous_type_d4ed57c78da46593_3#xform.[i].varcxx . . $ xform#var.[j] = 0.0; |
| 91 | cp->xformcxx . . $ $anonymous_type_d4ed57c78da46593_3#xform.[i].ccxx . . $ xform#c.[0][0] = 1.0; |
| 92 | cp->xformcxx . . $ $anonymous_type_d4ed57c78da46593_3#xform.[i].ccxx . . $ xform#c.[0][1] = 0.0; |
| 93 | cp->xformcxx . . $ $anonymous_type_d4ed57c78da46593_3#xform.[i].ccxx . . $ xform#c.[1][0] = 0.0; |
| 94 | cp->xformcxx . . $ $anonymous_type_d4ed57c78da46593_3#xform.[i].ccxx . . $ xform#c.[1][1] = 1.0; |
| 95 | cp->xformcxx . . $ $anonymous_type_d4ed57c78da46593_3#xform.[i].ccxx . . $ xform#c.[2][0] = 0.0; |
| 96 | cp->xformcxx . . $ $anonymous_type_d4ed57c78da46593_3#xform.[i].ccxx . . $ xform#c.[2][1] = 0.0; |
| 97 | } |
| 98 | |
| 99 | tokenizecxx . . $ tokenize(29c5cb4808ce8941).(ss, argv, &argc); |
| 100 | for (i = 0; i < argc; i++) { |
| 101 | if (streqlcxx . . $ `flam3-convert.c:23:9`!("xform", argv[i])) |
| 102 | slot = &xf; |
| 103 | else if (streqlcxx . . $ `flam3-convert.c:23:9`!("time", argv[i])) |
| 104 | slot = &cp->timecxx . . $ $anonymous_type_d4ed57c78da46593_3#time.; |
| 105 | else if (streqlcxx . . $ `flam3-convert.c:23:9`!("brightness", argv[i])) |
| 106 | slot = &cp->brightnesscxx . . $ $anonymous_type_d4ed57c78da46593_3#brightness.; |
| 107 | else if (streqlcxx . . $ `flam3-convert.c:23:9`!("contrast", argv[i])) |
| 108 | slot = &cp->contrastcxx . . $ $anonymous_type_d4ed57c78da46593_3#contrast.; |
| 109 | else if (streqlcxx . . $ `flam3-convert.c:23:9`!("gamma", argv[i])) |
| 110 | slot = &cp->gammacxx . . $ $anonymous_type_d4ed57c78da46593_3#gamma.; |
| 111 | else if (streqlcxx . . $ `flam3-convert.c:23:9`!("vibrancy", argv[i])) |
| 112 | slot = &cp->vibrancycxx . . $ $anonymous_type_d4ed57c78da46593_3#vibrancy.; |
| 113 | else if (streqlcxx . . $ `flam3-convert.c:23:9`!("hue_rotation", argv[i])) { |
| 114 | slot = &cp->hue_rotationcxx . . $ $anonymous_type_d4ed57c78da46593_3#hue_rotation.; |
| 115 | set_hr = 1; |
| 116 | } else if (streqlcxx . . $ `flam3-convert.c:23:9`!("zoom", argv[i])) |
| 117 | slot = &cp->zoomcxx . . $ $anonymous_type_d4ed57c78da46593_3#zoom.; |
| 118 | else if (streqlcxx . . $ `flam3-convert.c:23:9`!("image_size", argv[i])) { |
| 119 | slot = image_size; |
| 120 | set_image_size = 1; |
| 121 | } else if (streqlcxx . . $ `flam3-convert.c:23:9`!("center", argv[i])) |
| 122 | slot = cp->centercxx . . $ $anonymous_type_d4ed57c78da46593_3#center.; |
| 123 | else if (streqlcxx . . $ `flam3-convert.c:23:9`!("background", argv[i])) |
| 124 | slot = cp->backgroundcxx . . $ $anonymous_type_d4ed57c78da46593_3#background.; |
| 125 | else if (streqlcxx . . $ `flam3-convert.c:23:9`!("pixels_per_unit", argv[i])) |
| 126 | slot = &cp->pixels_per_unitcxx . . $ $anonymous_type_d4ed57c78da46593_3#pixels_per_unit.; |
| 127 | else if (streqlcxx . . $ `flam3-convert.c:23:9`!("spatial_filter_radius", argv[i])) |
| 128 | slot = &cp->spatial_filter_radiuscxx . . $ $anonymous_type_d4ed57c78da46593_3#spatial_filter_radius.; |
| 129 | else if (streqlcxx . . $ `flam3-convert.c:23:9`!("sample_density", argv[i])) |
| 130 | slot = &cp->sample_densitycxx . . $ $anonymous_type_d4ed57c78da46593_3#sample_density.; |
| 131 | else if (streqlcxx . . $ `flam3-convert.c:23:9`!("nbatches", argv[i])) { |
| 132 | slot = &nbatches; |
| 133 | set_nbatches = 1; |
| 134 | } else if (streqlcxx . . $ `flam3-convert.c:23:9`!("white_level", argv[i])) { |
| 135 | slot = &white_level; |
| 136 | set_white_level = 1; |
| 137 | } else if (streqlcxx . . $ `flam3-convert.c:23:9`!("spatial_oversample", argv[i])) { |
| 138 | slot = &spatial_oversample; |
| 139 | set_spatial_oversample = 1; |
| 140 | } else if (streqlcxx . . $ `flam3-convert.c:23:9`!("cmap", argv[i])) { |
| 141 | slot = &cm; |
| 142 | set_cm = 1; |
| 143 | } else if (streqlcxx . . $ `flam3-convert.c:23:9`!("palette", argv[i])) { |
| 144 | slot = &cp->palettecxx . . $ $anonymous_type_d4ed57c78da46593_3#palette.[0].colorcxx . . $ $anonymous_type_d4ed57c78da46593_0#color.[0]; |
| 145 | } else if (streqlcxx . . $ `flam3-convert.c:23:9`!("density", argv[i])) |
| 146 | slot = &cp->xformcxx . . $ $anonymous_type_d4ed57c78da46593_3#xform.[(int)xf].densitycxx . . $ xform#density.; |
| 147 | else if (streqlcxx . . $ `flam3-convert.c:23:9`!("color", argv[i])) |
| 148 | slot = &cp->xformcxx . . $ $anonymous_type_d4ed57c78da46593_3#xform.[(int)xf].colorcxx . . $ xform#color.; |
| 149 | else if (streqlcxx . . $ `flam3-convert.c:23:9`!("coefs", argv[i])) { |
| 150 | slot = cp->xformcxx . . $ $anonymous_type_d4ed57c78da46593_3#xform.[(int)xf].ccxx . . $ xform#c.[0]; |
| 151 | cp->xformcxx . . $ $anonymous_type_d4ed57c78da46593_3#xform.[(int)xf].densitycxx . . $ xform#density. = 1.0; |
| 152 | } else if (streqlcxx . . $ `flam3-convert.c:23:9`!("var", argv[i])) |
| 153 | slot = cp->xformcxx . . $ $anonymous_type_d4ed57c78da46593_3#xform.[(int)xf].varcxx . . $ xform#var.; |
| 154 | else if (streqlcxx . . $ `flam3-convert.c:23:9`!("cmap_inter", argv[i])) { |
| 155 | slot = &cmap_inter; |
| 156 | } else |
| 157 | *slot++ = atofcxx . . $ atof(9a18bdb0e56c1bc2).(argv[i]); |
| 158 | } |
| 159 | if (set_cm) { |
| 160 | double hr = set_hr ? cp->hue_rotationcxx . . $ $anonymous_type_d4ed57c78da46593_3#hue_rotation. : 0.0; |
| 161 | cp->palette_indexcxx . . $ $anonymous_type_d4ed57c78da46593_3#palette_index. = (int) cm; |
| 162 | flam3_get_palettecxx . . $ flam3_get_palette(4c7a1137c04ffabc).(cp->palette_indexcxx . . $ $anonymous_type_d4ed57c78da46593_3#palette_index., cp->palettecxx . . $ $anonymous_type_d4ed57c78da46593_3#palette., hr); |
| 163 | } |
| 164 | if (set_image_size) { |
| 165 | cp->widthcxx . . $ $anonymous_type_d4ed57c78da46593_3#width. = (int) image_size[0]; |
| 166 | cp->heightcxx . . $ $anonymous_type_d4ed57c78da46593_3#height. = (int) image_size[1]; |
| 167 | } |
| 168 | if (set_nbatches) |
| 169 | cp->nbatchescxx . . $ $anonymous_type_d4ed57c78da46593_3#nbatches. = (int) nbatches; |
| 170 | if (set_spatial_oversample) |
| 171 | cp->spatial_oversamplecxx . . $ $anonymous_type_d4ed57c78da46593_3#spatial_oversample. = (int) spatial_oversample; |
| 172 | if (set_white_level) { |
| 173 | /* ignore */ |
| 174 | } |
| 175 | for (i = 0; i < flam3_nxformscxx . . $ `flam3.h:72:9`!; i++) { |
| 176 | t = 0.0; |
| 177 | for (j = 0; j < flam3_nvariationscxx . . $ `flam3.h:71:9`!; j++) |
| 178 | t += cp->xformcxx . . $ $anonymous_type_d4ed57c78da46593_3#xform.[i].varcxx . . $ xform#var.[j]; |
| 179 | t = 1.0 / t; |
| 180 | for (j = 0; j < flam3_nvariationscxx . . $ `flam3.h:71:9`!; j++) |
| 181 | cp->xformcxx . . $ $anonymous_type_d4ed57c78da46593_3#xform.[i].varcxx . . $ xform#var.[j] *= t; |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | int |
| 186 | maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv) |
| 187 | { |
| 188 | char *s, *ss; |
| 189 | |
| 190 | #ifdef WIN32 |
| 191 | |
| 192 | char *slashloc; |
| 193 | char palpath[256],exepath[256]; |
| 194 | |
| 195 | slashloc = strrchr(argv[0],'\\'); |
| 196 | if (NULL==slashloc) { |
| 197 | sprintf(palpath,"flam3_palettes=flam3-palettes.xml"); |
| 198 | } else { |
| 199 | strncpy(exepath,argv[0],slashloc-argv[0]+1); |
| 200 | sprintf(palpath,"flam3_palettes=%sflam3-palettes.xml",exepath); |
| 201 | } |
| 202 | putenv(palpath); |
| 203 | |
| 204 | #endif |
| 205 | |
| 206 | if (1 != argc) { |
| 207 | docstringcxx . . $ docstring(d878ad36e69247c7).(); |
| 208 | exitcxx . . $ exit(3ca292c338df9bb3).(0); |
| 209 | } |
| 210 | |
| 211 | { |
| 212 | int i, c, slen = 5000; |
| 213 | s = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(slen); |
| 214 | i = 0; |
| 215 | do { |
| 216 | c = getcharcxx . . $ getchar(b126dc7c1de90089).(); |
| 217 | if (EOFcxx . . $ `<external>/232824719582829767/stdio.h:105:9`! == c) goto done_reading; |
| 218 | s[i++] = c; |
| 219 | if (i == slen-1) { |
| 220 | slen *= 2; |
| 221 | s = realloccxx . . $ realloc(417ab160f6baadc6).(s, slen); |
| 222 | } |
| 223 | } while (1); |
| 224 | done_reading: |
| 225 | s[i] = 0; |
| 226 | } |
| 227 | |
| 228 | ss = s; |
| 229 | s += strlencxx . . $ strlen(751346f8406fd082).(s); |
| 230 | printfcxx . . $ printf(581fddd72a8db8fc).("<conversions>\n"); |
| 231 | while (strchrcxx . . $ strchr(2050848944e00d54).(ss, ';')) { |
| 232 | flam3_genomecxx . . $ flam3_genome# cp; |
| 233 | parse_control_point_oldcxx . . $ parse_control_point_old(72567ccc91e2a81a).(&ss, &cp); |
| 234 | flam3_printcxx . . $ flam3_print(23fe5a5ee5da949e).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, &cp, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, flam3_print_editscxx . . $ `flam3.h:53:9`!); |
| 235 | } |
| 236 | printfcxx . . $ printf(581fddd72a8db8fc).("</conversions>\n"); |
| 237 | return 0; |
| 238 | } |