diff options
author | Christopher Bero | 2015-07-23 12:32:59 -0500 |
---|---|---|
committer | Christopher Bero | 2015-07-23 12:32:59 -0500 |
commit | 68e49bf3a0205917296aab93c74aea84e8cd5bd8 (patch) | |
tree | 92cca2588f8a2a7761988d8e58767f657f08bea8 /xmatrix-color.diff | |
parent | 650f4acfb4774d6fe48296a50e31b1dffed48afa (diff) | |
download | aur-68e49bf3a0205917296aab93c74aea84e8cd5bd8.tar.gz |
Update to 5.32-2
Diffstat (limited to 'xmatrix-color.diff')
-rw-r--r-- | xmatrix-color.diff | 221 |
1 files changed, 164 insertions, 57 deletions
diff --git a/xmatrix-color.diff b/xmatrix-color.diff index 8bd069e047c7..a00423a840d1 100644 --- a/xmatrix-color.diff +++ b/xmatrix-color.diff @@ -1,117 +1,224 @@ ---- hacks/xmatrix.c 2014-10-05 01:35:38.000000000 -0500 -+++ /home/berocs/Documents/xscreensaver/hacks/xmatrix.c 2015-07-09 00:19:43.175906299 -0500 -@@ -230,11 +230,97 @@ - int delay; - } m_state; +--- xmatrix.c 2014-10-05 01:35:38.000000000 -0500 ++++ xmatrix.c.mod 2015-07-23 12:28:13.674460728 -0500 +@@ -232,8 +232,97 @@ -+static void -+edit_image (Display *dpy, char ** bits, int which, const char * shift_text) + + static void ++edit_image (char ** bits, int which, const char * shift_text) +{ -+ char colors_text[3]; -+ char *hex; -+ char dark_hex[3]; -+ char light_hex[3]; -+ int colors_int; -+ int index; -+ int char_size; ++ /* Horrible kludge that will extrapolate the existing "green" ++ * color codes in the .xpm files to generate other basic ++ * RGB mixed colors with varied success. */ + -+ printf("\nColor Shift: %s", shift_text); -+ char_size=sizeof(char); -+ printf("\nBits: %s", bits[3]); ++ char colors_text[3]; /* Number of colors declared, must be double digit */ ++ char *hex; /* The entire hex char* array for a color */ ++ char dark_hex[3]; /* the two-digit value for a dark color */ ++ char light_hex[3]; /* the two-digit value for a light color */ ++ int colors_int; /* the integer corresponding to colors_text */ ++ int index; /* loop index */ ++ static const int sizeof_char = sizeof(char); ++ ++ /*printf("\nColor Shift: %s", shift_text);*/ ++ /*printf("\nBits: %s", bits[3]);*/ + colors_text[0] = bits[0][8]; + colors_text[1] = bits[0][9]; + colors_text[2] = '\0'; + colors_int = atoi(colors_text); -+ printf("\nNumber of colors: %i", colors_int); ++ /*printf("\nNumber of colors: %i", colors_int);*/ + for (index = 3; index <= colors_int; ++index) + { -+ hex = malloc(sizeof(char) * 12); -+ memmove(hex, bits[index], 11*char_size); -+ memmove(dark_hex, hex+5,2*char_size); -+ memmove(light_hex, hex+7,2*char_size); ++ /* Remember that when your college professor ++ * says "memory is cheap" that this is the ++ * road you are led down */ ++ hex = malloc(sizeof_char * 12); /* memory is cheap */ ++ memmove(hex, bits[index], 11*sizeof_char); ++ memmove(dark_hex, hex+5,2*sizeof_char); ++ memmove(light_hex, hex+7,2*sizeof_char); + dark_hex[2] = '\0'; + light_hex[2] = '\0'; + hex[11] = '\0'; -+ printf("\nhex: %s, Dark: %s, Light: %s", bits[index], dark_hex, light_hex); ++ /*printf("\nhex: %s, Dark: %s, Light: %s", bits[index], dark_hex, light_hex);*/ + if (!strcasecmp(shift_text, "yellow")) + { -+ memmove(hex+5, light_hex, 2*char_size); ++ memmove(hex+5, light_hex, 2*sizeof_char); + bits[index]=hex; -+ printf(" New Color: %s", bits[index]); + } + else if (!strcasecmp(shift_text, "red")) + { -+ memmove(hex+5, light_hex, 2*char_size); -+ memmove(hex+7, dark_hex, 2*char_size); ++ memmove(hex+5, light_hex, 2*sizeof_char); ++ memmove(hex+7, dark_hex, 2*sizeof_char); + bits[index]=hex; -+ printf(" New Color: %s", bits[index]); + } + else if (!strcasecmp(shift_text, "blue")) + { -+ memmove(hex+9, light_hex, 2*char_size); -+ memmove(hex+7, dark_hex, 2*char_size); ++ memmove(hex+9, light_hex, 2*sizeof_char); ++ memmove(hex+7, dark_hex, 2*sizeof_char); + bits[index]=hex; -+ printf(" New Color: %s", bits[index]); + } + else if (!strcasecmp(shift_text, "purple")) + { -+ memmove(hex+5, light_hex, 2*char_size); -+ memmove(hex+7, dark_hex, 2*char_size); -+ memmove(hex+9, light_hex, 2*char_size); ++ memmove(hex+5, light_hex, 2*sizeof_char); ++ memmove(hex+7, dark_hex, 2*sizeof_char); ++ memmove(hex+9, light_hex, 2*sizeof_char); + bits[index]=hex; -+ printf(" New Color: %s", bits[index]); + } + else if (!strcasecmp(shift_text, "aqua")) + { -+ memmove(hex+9, light_hex, 2*char_size); ++ memmove(hex+9, light_hex, 2*sizeof_char); + bits[index]=hex; -+ printf(" New Color: %s", bits[index]); + } + else if (!strcasecmp(shift_text, "white")) + { -+ memmove(hex+5, light_hex, 2*char_size); -+ memmove(hex+7, light_hex, 2*char_size); -+ memmove(hex+9, light_hex, 2*char_size); ++ memmove(hex+5, light_hex, 2*sizeof_char); ++ memmove(hex+7, light_hex, 2*sizeof_char); ++ memmove(hex+9, light_hex, 2*sizeof_char); + bits[index]=hex; -+ printf(" New Color: %s", bits[index]); + } + else if (!strcasecmp(shift_text, "grey")) + { -+ memmove(hex+5, dark_hex, 2*char_size); -+ memmove(hex+7, dark_hex, 2*char_size); -+ memmove(hex+9, dark_hex, 2*char_size); -+ bits[index]=hex; -+ printf(" New Color: %s", bits[index]); ++ memmove(hex+5, dark_hex, 2*sizeof_char); ++ memmove(hex+7, dark_hex, 2*sizeof_char); ++ memmove(hex+9, dark_hex, 2*sizeof_char); + } + else if (!strcasecmp(shift_text, "green")) + { + /* Really? */ + } ++ /*printf(" New Color: %s", bits[index]);*/ + } +} - - static void ++ ++ ++static void load_images_1 (Display *dpy, m_state *state, int which) { - #if defined(HAVE_GDK_PIXBUF) || defined(HAVE_XPM) ++ /* Get the -color-shift argument. */ + const char *shift_text = get_string_resource(dpy, "colorShift", "String"); ++ + #if defined(HAVE_GDK_PIXBUF) || defined(HAVE_XPM) if (!get_boolean_resource (dpy, "mono", "Boolean") && state->xgwa.depth > 1) - { -@@ -242,6 +328,12 @@ +@@ -242,6 +331,12 @@ (which == 1 ? (state->small_p ? matrix1b_xpm : matrix1_xpm) : (state->small_p ? matrix2b_xpm : matrix2_xpm)); + /* Edit 2D array of char data here */ + if (shift_text != NULL) + { -+ edit_image(dpy, bits, which, shift_text); ++ edit_image(bits, which, shift_text); + } + state->images[which] = xpm_data_to_pixmap (state->dpy, state->window, bits, &state->image_width, &state->image_height, 0); -@@ -1854,6 +1946,9 @@ +@@ -253,8 +348,16 @@ + unsigned long fg, bg; + state->image_width = (state->small_p ? matrix1b_width :matrix1_width); + state->image_height = (state->small_p ? matrix1b_height:matrix1_height); +- fg = get_pixel_resource(state->dpy, state->xgwa.colormap, +- "foreground", "Foreground"); ++ if (shift_text != NULL) ++ { ++ fg = get_pixel_resource(state->dpy, state->xgwa.colormap, ++ "colorShift", "Foreground"); ++ } ++ else ++ { ++ fg = get_pixel_resource(state->dpy, state->xgwa.colormap, ++ "foreground", "Foreground"); ++ } + bg = get_pixel_resource(state->dpy, state->xgwa.colormap, + "background", "Background"); + state->images[which] = +@@ -596,6 +699,40 @@ + } + + ++static int ++densitizer (int x) ++{ ++ /* Best fit curve to replace old table. ++ * Now you can twiddle single % values ++ * and its technically doing something. ++ * y = a * exp(b*x) ++ * See 'densitizer.sce' for comparison. */ ++ ++ /* Declare variables */ ++ double a, b; ++ int y; ++ ++ /* Clean input */ ++ if (x > 100) { ++ x = 100; ++ } ++ else if (x < 1) { ++ x = 1; ++ } ++ ++ /* Set exp function params */ ++ a=211.538187957; ++ b=-0.0488730165089; ++ ++ /* Calculate result, used in xmatrix_init() ++ * and hack_matrix() */ ++ y=a*exp(b*x); ++ ++ /*printf("\nDensitizer. x=%d, y=%d", x, y);*/ ++ return(y); ++} ++ ++ + static void * + xmatrix_init (Display *dpy, Window window) + { +@@ -673,7 +810,7 @@ + calloc (sizeof(m_cell), state->grid_width * state->grid_height); + state->feeders = (m_feeder *) calloc (sizeof(m_feeder), state->grid_width); + +- state->density = get_integer_resource (dpy, "density", "Integer"); ++ state->density = densitizer(get_integer_resource (dpy, "density", "Integer")); + + insert = get_string_resource(dpy, "insert", "Insert"); + if (insert && !strcmp(insert, "top")) +@@ -1082,28 +1219,6 @@ + } + + +-static int +-densitizer (m_state *state) +-{ +- /* Horrid kludge that converts percentages (density of screen coverage) +- to the parameter that actually controls this. I got this mapping +- empirically, on a 1024x768 screen. Sue me. */ +- if (state->density < 10) return 85; +- else if (state->density < 15) return 60; +- else if (state->density < 20) return 45; +- else if (state->density < 25) return 25; +- else if (state->density < 30) return 20; +- else if (state->density < 35) return 15; +- else if (state->density < 45) return 10; +- else if (state->density < 50) return 8; +- else if (state->density < 55) return 7; +- else if (state->density < 65) return 5; +- else if (state->density < 80) return 3; +- else if (state->density < 90) return 2; +- else return 1; +-} +- +- + static void + hack_text (m_state *state) + { +@@ -1503,7 +1618,7 @@ + if (f->remaining > 0) /* never change if pipe isn't empty */ + continue; + +- if ((random() % densitizer(state)) != 0) /* then change N% of the time */ ++ if ((random() % state->density) != 0) /* then change N% of the time */ + continue; + + f->remaining = 3 + (random() % state->grid_height); +@@ -1854,6 +1969,9 @@ { "-pipe", ".usePipe", XrmoptionNoArg, "True" }, { "-no-pipe", ".usePipe", XrmoptionNoArg, "False" }, { "-program", ".program", XrmoptionSepArg, 0 }, @@ -121,8 +228,8 @@ { 0, 0, 0, 0 } }; ---- hacks/config/xmatrix.xml 2015-06-13 18:08:53.000000000 -0500 -+++ /home/berocs/Documents/xscreensaver/hacks/config/xmatrix.xml 2015-07-09 00:19:43.175906299 -0500 +--- config/xmatrix.xml 2015-06-13 18:08:53.000000000 -0500 ++++ config/xmatrix.xml.mod 2015-07-23 12:28:13.691127249 -0500 @@ -25,6 +25,16 @@ <option id="top" _label="Slider algorithm" arg-set="-insert top"/> <option id="bottom" _label="Expansion algorithm" arg-set="-insert bottom"/> @@ -140,8 +247,8 @@ </hgroup> <hgroup> ---- hacks/xmatrix.man 2011-08-03 13:44:25.000000000 -0500 -+++ /home/berocs/Documents/xscreensaver/hacks/xmatrix.man 2015-07-09 00:19:43.175906299 -0500 +--- xmatrix.man 2011-08-03 13:44:25.000000000 -0500 ++++ xmatrix.man.mod 2015-07-23 12:28:13.697793858 -0500 @@ -26,6 +26,8 @@ [\-mode \fImode\fP] [\-phone \fInumber\fP] |