From de0a8d8ff492fe1ede5ae2b3bad3d3bf659934d1 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sun, 15 Feb 2015 17:27:22 +0100 Subject: Remove all uses of getenv Not much functionality lost here. Move on. --- flam3.c | 152 +++++-------------------------------------------------------- palettes.c | 3 +- parser.c | 7 +-- png.c | 43 ----------------- private.h | 5 -- rect.c | 17 +------ 6 files changed, 14 insertions(+), 213 deletions(-) diff --git a/flam3.c b/flam3.c index 64d04c5..c4464ed 100644 --- a/flam3.c +++ b/flam3.c @@ -274,84 +274,6 @@ flam3_genome *sheep_loop(flam3_genome *cp, double blend) { return(result); } - - - -flam3_genome *sheep_edge(flam3_genome *cp, double blend, int seqflag, double stagger) { - - flam3_genome spun[2]; - flam3_genome prealign[2]; - flam3_genome *result; - int i,si; - char *ai; - - memset(spun, 0, 2*sizeof(flam3_genome)); - memset(prealign, 0, 2*sizeof(flam3_genome)); - - /* Allocate the memory for the result */ - result = calloc(1,sizeof(flam3_genome)); - - /* - * Insert motion magic here : - * if there are motion elements, we will modify the contents of - * the prealign genomes before we rotate and interpolate. - */ - - for (si=0;si<2;si++) { - flam3_copy(&prealign[si], &cp[si]); - for (i=0;i0) { - /* Apply motion parameters to result.xform[i] using blend parameter */ - apply_motion_parameters(&cp[si].xform[i], &prealign[si].xform[i], blend); - } - } - } - - /* Use the un-padded original for blend=0 when creating a sequence */ - /* This keeps the original interpolation type intact */ - if (seqflag && 0.0 == blend) { - flam3_copy(result, &prealign[0]); - } else { - - /* Align what we're going to interpolate */ - flam3_align(spun, prealign, 2); - - spun[0].time = 0.0; - spun[1].time = 1.0; - - /* Call this first to establish the asymmetric reference angles */ - establish_asymmetric_refangles(spun,2); - - /* Rotate the aligned xforms */ - flam3_rotate(&spun[0], blend*360.0, spun[0].interpolation_type); - flam3_rotate(&spun[1], blend*360.0, spun[0].interpolation_type); - - /* Now call the interpolation */ - if (argi("unsmoother",0) == 0) - flam3_interpolate(spun, 2, smoother(blend), stagger, result); - else - flam3_interpolate(spun, 2, blend, stagger, result); - - - /* Interpolation type no longer needs to be forced to linear mode */ -// if (!seqflag) -// result.interpolation_type = flam3_inttype_linear; - } - - /* Clear the genomes we used */ - clear_cp(&spun[0],flam3_defaults_on); - clear_cp(&spun[1],flam3_defaults_on); - clear_cp(&prealign[0],flam3_defaults_on); - clear_cp(&prealign[1],flam3_defaults_on); - - /* Make sure there are no motion elements in the result */ - for (i=0;inum_xforms;i++) - flam3_delete_motion_elements(&result->xform[i]); - - return(result); -} - - /* BY is angle in degrees */ void flam3_rotate(flam3_genome *cp, double by, int interpolation_type) { int i; @@ -1457,8 +1379,6 @@ char *flam3_print_to_string(flam3_genome *cp) { void flam3_print(FILE *f, flam3_genome *cp, char *extra_attributes, int print_edits) { int i,numstd; - int flam27_flag; - char *ai; // force use of "C" locale when writing reals. // first save away the current settings. @@ -1476,8 +1396,6 @@ void flam3_print(FILE *f, flam3_genome *cp, char *extra_attributes, int print_ed fprintf(stderr, "error: couldn't set C locale\n"); - flam27_flag = argi("flam27",0); - fprintf(f, "time); if (cp->flame_name[0]!=0) @@ -1543,8 +1461,7 @@ void flam3_print(FILE *f, flam3_genome *cp, char *extra_attributes, int print_ed fprintf(f, " brightness=\"%g\"", cp->brightness); fprintf(f, " gamma=\"%g\"", cp->gamma); - if (!flam27_flag) - fprintf(f, " highlight_power=\"%g\"", cp->highlight_power); + fprintf(f, " highlight_power=\"%g\"", cp->highlight_power); fprintf(f, " vibrancy=\"%g\"", cp->vibrancy); fprintf(f, " gamma_threshold=\"%g\"", cp->gam_lin_thresh); @@ -1589,32 +1506,6 @@ void flam3_print(FILE *f, flam3_genome *cp, char *extra_attributes, int print_ed } - int hexpalette = argi("hexpalette",0); - - if (hexpalette) { - - fprintf(f," "); - - for (i=0; i < 256; i++) { - - int r, g, b; - r = rint(cp->palette[i].color[0] * 255.0); - g = rint(cp->palette[i].color[1] * 255.0); - b = rint(cp->palette[i].color[2] * 255.0); - - if (i % 8 == 0) { - fprintf(f,"\n"); - fprintf(f," "); - } - - fprintf(f,"%2x%2x%2x",r,g,b); - - } - - fprintf(f,"\n"); - fprintf(f," \n"); - - } else { for (i = 0; i < 256; i++) { double r, g, b, a; r = (cp->palette[i].color[0] * 255.0); @@ -1624,27 +1515,16 @@ void flam3_print(FILE *f, flam3_genome *cp, char *extra_attributes, int print_ed fprintf(f, " "); - if (flam27_flag || a==255.0) { - - if (flam27_flag && a!=255.0) - fprintf(stderr,"alpha channel in palette cannot be stored in 2.7 compatibility mode; truncating\n"); + if (a==255.0) { - if (getenv("intpalette")) - fprintf(f, "", i, (int)rint(r), (int)rint(g), (int)rint(b)); - else { - fprintf(f, "", i, r, g, b); - } + fprintf(f, "", i, r, g, b); } else { - if (getenv("intpalette")) - fprintf(f, " ", i, (int)rint(r), (int)rint(g), (int)rint(b), (int)rint(a)); - else - fprintf(f, " ", i, r, g, b, a); + fprintf(f, " ", i, r, g, b, a); } // if (i%4 == 3) fprintf(f, "\n"); } - } if (cp->edits != NULL && print_edits==flam3_print_edits) { @@ -1680,12 +1560,6 @@ void flam3_print_xform(FILE *f, flam3_xform *x, int final_flag, int numstd, doub int j; int lnv; - int flam27_flag; - char *ai; - - flam27_flag = argi("flam27",0); - - /* Motion flag will not be set if flam27_flag is set */ if (motion_flag) { fprintf(f, " motion_freq); if (x->motion_func == MOTION_SIN) @@ -1704,15 +1578,13 @@ void flam3_print_xform(FILE *f, flam3_xform *x, int final_flag, int numstd, doub if (!motion_flag || x->color != 0.0) fprintf(f, "color=\"%g\" ", x->color); - if (flam27_flag) - fprintf(f, "symmetry=\"%g\" ", 1.0-2.0*x->color_speed); - else if (!motion_flag) + if (!motion_flag) fprintf(f, "color_speed=\"%g\" ", x->color_speed); - if (!final_flag && !motion_flag && !flam27_flag) + if (!final_flag && !motion_flag) fprintf(f, "animate=\"%g\" ", x->animate); - lnv = flam27_flag ? 54:flam3_nvariations; + lnv = flam3_nvariations; for (j = 0; j < lnv; j++) { double v = x->var[j]; @@ -2209,7 +2081,7 @@ void flam3_print_xform(FILE *f, flam3_xform *x, int final_flag, int numstd, doub } } - if (!final_flag && !motion_flag && !flam27_flag) { + if (!final_flag && !motion_flag) { /* Print out the chaos row for this xform */ int numcols = numstd; @@ -2227,11 +2099,11 @@ void flam3_print_xform(FILE *f, flam3_xform *x, int final_flag, int numstd, doub } - if (!flam27_flag && !motion_flag) { + if (!motion_flag) { fprintf(f, " opacity=\"%g\"",x->opacity); } - if (!motion_flag && x->num_motion>0 && !flam27_flag) { + if (!motion_flag && x->num_motion>0) { int nm; fprintf(f,">\n"); @@ -2751,9 +2623,7 @@ void flam3_random(flam3_genome *cp, int *ivars, int ivars_n, int sym, int spec_x int i, nxforms, var, samed, multid, samepost, postid, addfinal=0; int finum = -1; int n; - char *ai; - int f27 = argi("flam27",0); - int mvar = f27 ? 54 : flam3_nvariations; + int mvar = flam3_nvariations; double sum; static int xform_distrib[] = { diff --git a/palettes.c b/palettes.c index dd7f14a..eb5700b 100644 --- a/palettes.c +++ b/palettes.c @@ -150,8 +150,7 @@ int flam3_get_palette(int n, flam3_palette c, double hue_rotation, randctx * con } if (NULL == the_palettes) { - char *d = getenv("flam3_palettes"); - rcode = init_palettes(d ? d : ("flam3-palettes.xml")); + rcode = init_palettes("flam3-palettes.xml"); if (rcode<0) { fprintf(stderr,"error reading xml palette file, setting to all white\n"); return(-1); diff --git a/parser.c b/parser.c index d27bbe1..ee1aa18 100644 --- a/parser.c +++ b/parser.c @@ -1247,14 +1247,9 @@ void flam3_edit_print(FILE *f, xmlNodePtr editNode, int tabs, int formatting) { xmlAttrPtr att_ptr=NULL,cur_att=NULL; xmlNodePtr chld_ptr=NULL, cur_chld=NULL; int indent_printed = 0; - char *ai; - int tablim = argi("print_edit_depth",0); char *att_str,*cont_str,*cpy_string; - if (tablim>0 && tabs>tablim) - return; - /* If this node is an XML_ELEMENT_NODE, print it and it's attributes */ if (editNode->type==XML_ELEMENT_NODE) { @@ -1283,7 +1278,7 @@ void flam3_edit_print(FILE *f, xmlNodePtr editNode, int tabs, int formatting) { } /* Does this node have children? */ - if (!editNode->children || (tablim>0 && tabs>tablim)) { + if (!editNode->children) { /* Close the tag and subtract the tab */ fprintf(f,"/>"); if (formatting) diff --git a/png.c b/png.c index a2917f5..1c28172 100644 --- a/png.c +++ b/png.c @@ -32,47 +32,9 @@ void write_png(FILE *file, void *image, int width, int height, flam3_img_comments *fpc, int bpc) { png_structp png_ptr; png_infop info_ptr; - png_text text[FLAM3_PNG_COM]; size_t i; unsigned short testbe = 1; void **rows = malloc(sizeof(void *) * height); - char *nick = getenv("nick"); - char *url = getenv("url"); - char *id = getenv("id"); - char *ai; /* For argi */ - int pngcom_enable = argi("enable_png_comments", 1); - - text[0].compression = PNG_TEXT_COMPRESSION_NONE; - text[0].key = "flam3_version"; - text[0].text = flam3_version(); - - text[1].compression = PNG_TEXT_COMPRESSION_NONE; - text[1].key = "flam3_nickname"; - text[1].text = nick; - - text[2].compression = PNG_TEXT_COMPRESSION_NONE; - text[2].key = "flam3_url"; - text[2].text = url; - - text[3].compression = PNG_TEXT_COMPRESSION_NONE; - text[3].key = "flam3_id"; - text[3].text = id; - - text[4].compression = PNG_TEXT_COMPRESSION_NONE; - text[4].key = "flam3_error_rate"; - text[4].text = fpc->badvals; - - text[5].compression = PNG_TEXT_COMPRESSION_NONE; - text[5].key = "flam3_samples"; - text[5].text = fpc->numiters; - - text[6].compression = PNG_TEXT_COMPRESSION_NONE; - text[6].key = "flam3_time"; - text[6].text = fpc->rtime; - - text[7].compression = PNG_TEXT_COMPRESSION_zTXt; - text[7].key = "flam3_genome"; - text[7].text = fpc->genome; for (i = 0; i < height; i++) rows[i] = (unsigned char *)image + i * width * 4 * bpc; @@ -95,11 +57,6 @@ void write_png(FILE *file, void *image, int width, int height, flam3_img_comment PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); -#if 0 - if (pngcom_enable==1) - png_set_text(png_ptr, info_ptr, text, FLAM3_PNG_COM); -#endif - png_write_info(png_ptr, info_ptr); /* Must set this after the write_info */ diff --git a/private.h b/private.h index 3e5a9b3..ff207e4 100644 --- a/private.h +++ b/private.h @@ -44,11 +44,6 @@ #define max_specified_vars (100) #define vlen(x) (sizeof(x)/sizeof(*x)) - -#define argi(s,d) ((ai = getenv(s)) ? atoi(ai) : (d)) -#define argf(s,d) ((ai = getenv(s)) ? atof(ai) : (d)) -#define args(s,d) ((ai = getenv(s)) ? ai : (d)) - /* Structures for passing parameters to iteration threads */ typedef struct { unsigned short *xform_distrib; /* Distribution of xforms based on weights */ diff --git a/rect.c b/rect.c index b86e540..f06e382 100644 --- a/rect.c +++ b/rect.c @@ -287,7 +287,6 @@ int render_rectangle(flam3_frame *spec, void *out, int thi; time_t tstart,tend; double sumfilt; - char *ai; int cmap_size; /* Per-render progress timers */ @@ -304,7 +303,7 @@ int render_rectangle(flam3_frame *spec, void *out, stats->num_iters = 0; /* correct for apophysis's use of 255 colors in the palette rather than all 256 */ - cmap_size = 256 - argi("apo_palette",0); + cmap_size = 256; memset(&cp,0, sizeof(flam3_genome)); @@ -818,20 +817,6 @@ int render_rectangle(flam3_frame *spec, void *out, free(fth); clear_cp(&cp,0); - if (getenv("insert_palette")) { - int ph = 100; - if (ph >= image_height) ph = image_height; - /* insert the palette into the image */ - for (j = 0; j < ph; j++) { - for (i = 0; i < image_width; i++) { - unsigned char *p = (unsigned char *)out + nchan * (i + j * out_width); - p[0] = (unsigned char)dmap[i * 256 / image_width].color[0]; - p[1] = (unsigned char)dmap[i * 256 / image_width].color[1]; - p[2] = (unsigned char)dmap[i * 256 / image_width].color[2]; - } - } - } - tend = time(NULL); stats->render_seconds = (int)(tend-tstart); -- cgit v1.2.3