Make the "red stuff is new stuff" fade a lot prettier.
authorSteinar H. Gunderson <sesse@samfundet.no>
Sun, 20 Feb 2005 14:33:21 +0000 (14:33 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Sun, 20 Feb 2005 14:33:21 +0000 (14:33 +0000)
bigscreen/fonts.cpp
bigscreen/rotatescreen.cpp

index 2a7d274..8ba809f 100644 (file)
@@ -71,11 +71,11 @@ unsigned my_draw_text(const widestring &str, unsigned char *buf, double size, in
 
                                int width = (x + xpos + slot->bitmap_left + bm->width >= 800) ? (799 - x - xpos - slot->bitmap_left) : bm->width;
                                for (xx = 0; xx < width; xx++) {
-                                       *dst = (*dst * (256-*src) + r * *src) >> 8;
+                                       *dst = (*dst * (256-*src) + b * *src) >> 8;
                                        *dst++;
                                        *dst = (*dst * (256-*src) + g * *src) >> 8;
                                        *dst++;
-                                       *dst = (*dst * (256-*src) + b * *src) >> 8;
+                                       *dst = (*dst * (256-*src) + r * *src) >> 8;
                                        *dst++;
                                        *dst++ = 0;
                                        src++;
index 47f9095..1dba1cc 100644 (file)
@@ -44,18 +44,20 @@ void RotateScreen::draw(unsigned char *buf)
                
                if (elapsed_fade > 5.0 || (!same_fade && elapsed_fade > 0.5)) {
                        in_fade = false;
+
+                       // ugly hack here? :-)
+                       subscreens[current_screen].screen->draw(subscreens[current_screen].buf);
+                       
                        memcpy(buf, subscreens[current_screen].buf, 800 * 600 * 4);
                        printf("fade done\n");
                } else {
                        // find the fade factors
                        int fr, fg, fb, fa;
                        if (same_fade) {
-                               fr = unsigned(elapsed_fade/0.5 * 256.0);
                                if (elapsed_fade < 0.5) {
-                                       fg = fb = fa = 0;
+                                       fr = fg = fb = fa = unsigned(elapsed_fade/0.5 * 256.0);
                                } else {
-                                       fr = 256;
-                                       fg = fb = fa = unsigned((elapsed_fade-0.5)/4.5 * 256.0);
+                                       fr = fg = fb = fa = unsigned((elapsed_fade-0.5)/4.5 * 256.0);
                                }
                        } else {
                                fr = fg = fb = fa = unsigned(elapsed_fade/0.5 * 256.0);
@@ -66,17 +68,13 @@ void RotateScreen::draw(unsigned char *buf)
                        unsigned char *sptr2 = subscreens[current_screen].buf;
                        unsigned char *dptr = buf;
 
-                       if (same_fade) {
+                       if (same_fade && elapsed_fade >= 0.5) {
+                               // fade G&B to be = R
                                for (unsigned i = 0; i < 800 * 600; ++i) {
-                                       dptr[0] = sptr1[0] + (((int(sptr2[0]) - int(sptr1[0])) * fb) >> 8);
-                                       dptr[1] = sptr1[1] + (((int(sptr2[1]) - int(sptr1[1])) * fg) >> 8);
-                                       dptr[2] = sptr1[2] + (((int(sptr2[2]) - int(sptr1[2])) * fr) >> 8);
-                                       dptr[3] = sptr1[3] + (((int(sptr2[3]) - int(sptr1[3])) * fa) >> 8);
-
-                                       if (dptr[0] > dptr[2])
-                                               dptr[0] = dptr[2];
-                                       if (dptr[1] > dptr[2])
-                                               dptr[1] = dptr[2];
+                                       dptr[0] = sptr2[0] + (((int(sptr2[2]) - int(sptr2[0])) * fb) >> 8);
+                                       dptr[1] = sptr2[1] + (((int(sptr2[2]) - int(sptr2[1])) * fg) >> 8);
+                                       dptr[2] = sptr2[2];
+                                       dptr[3] = sptr2[3];
 
                                        sptr1 += 4, sptr2 += 4, dptr += 4;
                                }