Showing the changes to test.c (1 of 1 file). Show all
Unified · Split
| @@ -38,16 +38,15 @@ struct Sfont { · 37 unmodified lines | ||
| 38 | 38 | |
| 39 | 39 | static Sfont fo; |
| 40 | 40 | static Image *image; |
| 41 | +static int invert = 0; | |
| 41 | 42 | int mainstacksize = 32768; |
| 42 | 43 | |
| 43 | 44 | static void |
| 44 | 45 | redraw(void) |
| 45 | 46 | { |
| 46 | 47 | lockdisplay(display); |
| 47 | − draw(screen, screen->r, display->white, nil, ZP); | |
| 48 | − | |
| 48 | + draw(screen, screen->r, invert ? display->black : display->white, nil, ZP); | |
| 49 | 49 | draw(screen, screen->r, image, nil, ZP); |
| 50 | − | |
| 51 | 50 | flushimage(display, 1); |
| 52 | 51 | unlockdisplay(display); |
| 53 | 52 | } |
| @@ -161,8 +160,10 @@ prepare(float height, char *s) · 107 unmodified lines | ||
| 161 | 160 | |
| 162 | 161 | freeimage(image); |
| 163 | 162 | image = allocimage(display, rect, GREY8, 0, DNofill); |
| 164 | − for(i = 0; i < w*h+60; i++) | |
| 165 | − p[i] = 255 - p[i]; | |
| 163 | + if(!invert){ | |
| 164 | + for(i = 0; i < w*h+60; i++) | |
| 165 | + p[i] = 255 - p[i]; | |
| 166 | + } | |
| 166 | 167 | loadimage(image, rect, p, n); |
| 167 | 168 | free(p); |
| 168 | 169 | } |
| @@ -208,10 +209,11 @@ threadmain(int argc, char **argv) · 39 unmodified lines | ||
| 208 | 209 | a[2].c = kctl->c; |
| 209 | 210 | memimageinit(); |
| 210 | 211 | height = 32.0; |
| 212 | + oldy = 0; | |
| 211 | 213 | |
| 212 | 214 | for(;;){ |
| 213 | 215 | oldb = m.buttons; |
| 214 | − prepare(height, "Hello there, 9fans. ljil|."); | |
| 216 | + prepare(height, argc > 2 ? argv[2] : "Hello there, 9fans. ljil|."); | |
| 215 | 217 | redraw(); |
| 216 | 218 | |
| 217 | 219 | switch(alt(a)){ |
| @@ -219,9 +221,11 @@ threadmain(int argc, char **argv) · 1 unmodified line | ||
| 219 | 221 | if(m.buttons == 1){ |
| 220 | 222 | if(oldb == 0) |
| 221 | 223 | oldy = m.xy.y; |
| 222 | − height += (m.xy.y - oldy)/10.0; | |
| 223 | − if(height < 4) | |
| 224 | − height = 4; | |
| 224 | + else{ | |
| 225 | + height += (m.xy.y - oldy)/10.0; | |
| 226 | + if(height < 4) | |
| 227 | + height = 4; | |
| 228 | + } | |
| 225 | 229 | } |
| 226 | 230 | break; |
| 227 | 231 | |
| @@ -241,6 +245,9 @@ threadmain(int argc, char **argv) · 13 unmodified lines | ||
| 241 | 245 | case '+': |
| 242 | 246 | height += 2; |
| 243 | 247 | break; |
| 248 | + case 'i': | |
| 249 | + invert = !invert; | |
| 250 | + break; | |
| 244 | 251 | } |
| 245 | 252 | } |
| 246 | 253 | } |