summarylogtreecommitdiffstats
path: root/xmatrix-color.diff
blob: 8bd069e047c79eda94295e28dcb3447ea4b098da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
--- 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;
 
+static void
+edit_image (Display *dpy, 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;
+	
+	printf("\nColor Shift: %s", shift_text);
+	char_size=sizeof(char);
+	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);
+	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);
+		dark_hex[2] = '\0';
+		light_hex[2] = '\0';
+		hex[11] = '\0';
+		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);
+			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);
+			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);
+			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);
+			bits[index]=hex;
+			printf(" New Color: %s", bits[index]);
+		}
+		else if (!strcasecmp(shift_text, "aqua"))
+		{
+			memmove(hex+9, light_hex, 2*char_size);
+			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);
+			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]);
+		}
+		else if (!strcasecmp(shift_text, "green"))
+		{
+			/* Really? */
+		}
+	}
+}
 
 static void
 load_images_1 (Display *dpy, m_state *state, int which)
 {
 #if defined(HAVE_GDK_PIXBUF) || defined(HAVE_XPM)
+  const char *shift_text = get_string_resource(dpy, "colorShift", "String");
   if (!get_boolean_resource (dpy, "mono", "Boolean") &&
       state->xgwa.depth > 1)
     {
@@ -242,6 +328,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);
+		}
+
       state->images[which] =
         xpm_data_to_pixmap (state->dpy, state->window, bits,
                             &state->image_width, &state->image_height, 0);
@@ -1854,6 +1946,9 @@
   { "-pipe",	        ".usePipe",		XrmoptionNoArg, "True" },
   { "-no-pipe",	        ".usePipe",		XrmoptionNoArg, "False" },
   { "-program",	        ".program",		XrmoptionSepArg, 0 },
+  { "-bg",	        ".background",		XrmoptionSepArg, 0 },
+  { "-fg",	        ".foreground",		XrmoptionSepArg, 0 },
+  { "-color-shift",	        ".colorShift",		XrmoptionSepArg, 0 },
   { 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
@@ -25,6 +25,16 @@
      <option id="top"    _label="Slider algorithm"    arg-set="-insert top"/>
      <option id="bottom" _label="Expansion algorithm" arg-set="-insert bottom"/>
    </select>
+   
+   <select id="color">
+	   <option id="color_green" _label="Green"/>
+     <option id="color_blue" _label="Blue"  arg-set="-color-shift blue"/>
+     <option id="color_red" _label="Red"  arg-set="-color-shift red"/>
+     <option id="color_yellow" _label="Yellow"  arg-set="-color-shift yellow"/>
+     <option id="color_aqua" _label="Aqua"  arg-set="-color-shift aqua"/>
+     <option id="color_white" _label="White"  arg-set="-color-shift White"/>
+     <option id="color_grey" _label="Grey"  arg-set="-color-shift grey"/>
+   </select>
   </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
@@ -26,6 +26,8 @@
 [\-mode \fImode\fP]
 [\-phone \fInumber\fP]
 [\-fps]
+[\-mono [\-fg #XXXXXX] [\-bg #XXXXXX]]
+[\-color\-shift "color"]
 .SH DESCRIPTION
 The \fIxmatrix\fP program draws the 2D "digital rain" effect, as seen on
 the computer monitors in the Wachowski brothers' film, "The Matrix".
@@ -120,6 +122,16 @@
 xmatrix -ascii -program 'ps -eo comm | rev'
 xmatrix -program 'od -txC -w6 /dev/random'
 xmatrix -program 'cat /dev/random'
+
+.TP 8
+.B \-mono
+Force use of XBM files, which only allows one foreground color.
+Set custom hex colors with -fg and -bg.
+.TP 8
+.B \-color-shift
+Specify a simple color shift to one of:
+red, blue, green, purple, yellow, aqua, white, grey
+
 .EE
 .SH ENVIRONMENT
 .PP