Changeset 1243 for toilet/trunk/src/filter.c
- Timestamp:
- Oct 26, 2006, 3:30:14 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
toilet/trunk/src/filter.c
r1241 r1243 29 29 #include "filter.h" 30 30 31 static void filter_crop(c ucul_canvas_t *);32 static void filter_gay(c ucul_canvas_t *);33 static void filter_metal(c ucul_canvas_t *);34 static void filter_flip(c ucul_canvas_t *);35 static void filter_flop(c ucul_canvas_t *);36 static void filter_rotate(c ucul_canvas_t *);31 static void filter_crop(context_t *); 32 static void filter_gay(context_t *); 33 static void filter_metal(context_t *); 34 static void filter_flip(context_t *); 35 static void filter_flop(context_t *); 36 static void filter_rotate(context_t *); 37 37 38 38 struct 39 39 { 40 40 char const *name; 41 void (*function)(c ucul_canvas_t *);41 void (*function)(context_t *); 42 42 } 43 43 const lookup[] = … … 93 93 94 94 for(i = 0; i < cx->nfilters; i++) 95 cx->filters[i](cx ->torender);95 cx->filters[i](cx); 96 96 97 97 return 0; … … 105 105 } 106 106 107 static void filter_crop(c ucul_canvas_t *cv)107 static void filter_crop(context_t *cx) 108 108 { 109 109 unsigned int x, y, w, h; 110 110 unsigned int xmin, xmax, ymin, ymax; 111 111 112 xmin = w = cucul_get_canvas_width(c v);112 xmin = w = cucul_get_canvas_width(cx->torender); 113 113 xmax = 0; 114 ymin = h = cucul_get_canvas_height(c v);114 ymin = h = cucul_get_canvas_height(cx->torender); 115 115 ymax = 0; 116 116 … … 118 118 for(x = 0; x < w; x++) 119 119 { 120 unsigned long int ch = cucul_getchar(c v, x, y);120 unsigned long int ch = cucul_getchar(cx->torender, x, y); 121 121 if(ch != (unsigned char)' ') 122 122 { … … 135 135 return; 136 136 137 cucul_set_canvas_boundaries(c v, xmin, ymin,137 cucul_set_canvas_boundaries(cx->torender, xmin, ymin, 138 138 xmax - xmin + 1, ymax - ymin + 1); 139 139 } 140 140 141 static void filter_metal(c ucul_canvas_t *cv)141 static void filter_metal(context_t *cx) 142 142 { 143 143 static unsigned char const palette[] = … … 151 151 unsigned int x, y, w, h; 152 152 153 w = cucul_get_canvas_width(c v);154 h = cucul_get_canvas_height(c v);153 w = cucul_get_canvas_width(cx->torender); 154 h = cucul_get_canvas_height(cx->torender); 155 155 156 156 for(y = 0; y < h; y++) 157 157 for(x = 0; x < w; x++) 158 158 { 159 unsigned long int ch = cucul_getchar(c v, x, y);159 unsigned long int ch = cucul_getchar(cx->torender, x, y); 160 160 int i; 161 161 … … 163 163 continue; 164 164 165 i = y * 4 / h;166 cucul_set_color(c v, palette[i], CUCUL_COLOR_TRANSPARENT);167 cucul_putchar(c v, x, y, ch);168 } 169 } 170 171 static void filter_gay(c ucul_canvas_t *cv)165 i = ((cx->lines + y + x / 8) / 2) % 4; 166 cucul_set_color(cx->torender, palette[i], CUCUL_COLOR_TRANSPARENT); 167 cucul_putchar(cx->torender, x, y, ch); 168 } 169 } 170 171 static void filter_gay(context_t *cx) 172 172 { 173 173 static unsigned char const rainbow[] = … … 182 182 unsigned int x, y, w, h; 183 183 184 w = cucul_get_canvas_width(c v);185 h = cucul_get_canvas_height(c v);184 w = cucul_get_canvas_width(cx->torender); 185 h = cucul_get_canvas_height(cx->torender); 186 186 187 187 for(y = 0; y < h; y++) 188 188 for(x = 0; x < w; x++) 189 189 { 190 unsigned long int ch = cucul_getchar(c v, x, y);190 unsigned long int ch = cucul_getchar(cx->torender, x, y); 191 191 if(ch != (unsigned char)' ') 192 192 { 193 cucul_set_color(c v, rainbow[(x / 2 + y) % 6],193 cucul_set_color(cx->torender, rainbow[(x / 2 + y + cx->lines) % 6], 194 194 CUCUL_COLOR_TRANSPARENT); 195 cucul_putchar(c v, x, y, ch);195 cucul_putchar(cx->torender, x, y, ch); 196 196 } 197 197 } 198 198 } 199 199 200 static void filter_flip(c ucul_canvas_t *cv)201 { 202 cucul_flip(c v);203 } 204 205 static void filter_flop(c ucul_canvas_t *cv)206 { 207 cucul_flop(c v);208 } 209 210 static void filter_rotate(c ucul_canvas_t *cv)211 { 212 cucul_rotate(c v);213 } 214 200 static void filter_flip(context_t *cx) 201 { 202 cucul_flip(cx->torender); 203 } 204 205 static void filter_flop(context_t *cx) 206 { 207 cucul_flop(cx->torender); 208 } 209 210 static void filter_rotate(context_t *cx) 211 { 212 cucul_rotate(cx->torender); 213 } 214
Note: See TracChangeset
for help on using the changeset viewer.