History

inversion and custom text

Sigrid Haflínudóttir committed 6 years ago

Commit 85ecda81 parent 67208c41 file · +16 −9Browse files

Unified · Split

test.c+16−9
@@ -38,16 +38,15 @@ struct Sfont { · 37 unmodified lines
3838
3939 static Sfont fo;
4040 static Image *image;
41+static int invert = 0;
4142 int mainstacksize = 32768;
4243
4344 static void
4445 redraw(void)
4546 {
4647 lockdisplay(display);
47− draw(screen, screen->r, display->white, nil, ZP);
48−
48+ draw(screen, screen->r, invert ? display->black : display->white, nil, ZP);
4949 draw(screen, screen->r, image, nil, ZP);
50−
5150 flushimage(display, 1);
5251 unlockdisplay(display);
5352 }
@@ -161,8 +160,10 @@ prepare(float height, char *s) · 107 unmodified lines
161160
162161 freeimage(image);
163162 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+ }
166167 loadimage(image, rect, p, n);
167168 free(p);
168169 }
@@ -208,10 +209,11 @@ threadmain(int argc, char **argv) · 39 unmodified lines
208209 a[2].c = kctl->c;
209210 memimageinit();
210211 height = 32.0;
212+ oldy = 0;
211213
212214 for(;;){
213215 oldb = m.buttons;
214− prepare(height, "Hello there, 9fans. ljil|.");
216+ prepare(height, argc > 2 ? argv[2] : "Hello there, 9fans. ljil|.");
215217 redraw();
216218
217219 switch(alt(a)){
@@ -219,9 +221,11 @@ threadmain(int argc, char **argv) · 1 unmodified line
219221 if(m.buttons == 1){
220222 if(oldb == 0)
221223 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+ }
225229 }
226230 break;
227231
@@ -241,6 +245,9 @@ threadmain(int argc, char **argv) · 13 unmodified lines
241245 case '+':
242246 height += 2;
243247 break;
248+ case 'i':
249+ invert = !invert;
250+ break;
244251 }
245252 }
246253 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t