Ignore:
Timestamp:
Nov 13, 2006, 2:34:06 PM (13 years ago)
Author:
Sam Hocevar
Message:
  • Add more randomness to the cacademo effects.
  • Adapt the swallow test to the display's size.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/src/cacademo.c

    r1386 r1387  
    307307
    308308            red[i] = (1.0 + sin(z + r[1] * frame)) / 2 * 0xfff;
    309             blue[i] = (1.0 + cos(z + r[0] * frame)) / 2 * 0xfff;
    310             green[i] = (1.0 + cos(z + r[2] * frame)) / 2 * 0xfff;
     309            blue[i] = (1.0 + cos(z + r[0] * (frame + 100))) / 2 * 0xfff;
     310            green[i] = (1.0 + cos(z + r[2] * (frame + 200))) / 2 * 0xfff;
    311311        }
    312312
     
    379379    static float i = 10.0, j = 17.0, k = 11.0;
    380380    static double offset[360 + 80];
     381    static unsigned int angleoff;
    381382
    382383    int n, angle;
     
    400401            dk[n] = (float)cucul_rand(500, 4000) / 6000.0;
    401402        }
     403
     404        angleoff = cucul_rand(0, 360);
    402405
    403406        for(n = 0; n < 360 + 80; n++)
     
    414417
    415418    case UPDATE:
    416         angle = frame % 360;
     419        angle = (frame + angleoff) % 360;
    417420
    418421        /* Crop the palette */
     
    522525    static cucul_dither_t *dither;
    523526    static uint8_t *screen;
     527    static float d[6];
    524528    static unsigned int red[256], green[256], blue[256], alpha[256];
    525529
     
    533537            red[i] = green[i] = blue[i] = alpha[i] = 0;
    534538
     539        for(i = 0; i < 6; i++)
     540            d[i] = ((float)cucul_rand(50, 70)) / 1000.0;
     541
    535542        red[0] = green[0] = blue[0] = 0x777;
    536543        red[1] = green[1] = blue[1] = 0xfff;
     
    543550            for(t = 0, dx = 0, dy = i; dx <= dy; dx++)
    544551            {
    545                 draw_line(dx / 3,   dy / 3, (i / DISCTHICKNESS) % 2);
    546                 draw_line(dy / 3,   dx / 3, (i / DISCTHICKNESS) % 2);
     552                draw_line(dx / 3, dy / 3, (i / DISCTHICKNESS) % 2);
     553                draw_line(dy / 3, dx / 3, (i / DISCTHICKNESS) % 2);
    547554       
    548555                t += t > 0 ? dx - dy-- : dx;
     
    561568
    562569        /* Set the palette */
    563         red[0] = 0.5 * (1 + sin(0.05 * frame)) * 0xfff;
    564         green[0] = 0.5 * (1 + cos(0.07 * frame)) * 0xfff;
    565         blue[0] = 0.5 * (1 + cos(0.06 * frame)) * 0xfff;
    566 
    567         red[1] = 0.5 * (1 + sin(0.07 * frame + 5.0)) * 0xfff;
    568         green[1] = 0.5 * (1 + cos(0.06 * frame + 5.0)) * 0xfff;
    569         blue[1] = 0.5 * (1 + cos(0.05 * frame + 5.0)) * 0xfff;
     570        red[0] = 0.5 * (1 + sin(d[0] * (frame + 1000))) * 0xfff;
     571        green[0] = 0.5 * (1 + cos(d[1] * frame)) * 0xfff;
     572        blue[0] = 0.5 * (1 + cos(d[2] * (frame + 3000))) * 0xfff;
     573
     574        red[1] = 0.5 * (1 + sin(d[3] * (frame + 2000))) * 0xfff;
     575        green[1] = 0.5 * (1 + cos(d[4] * frame + 5.0)) * 0xfff;
     576        blue[1] = 0.5 * (1 + cos(d[5] * (frame + 4000))) * 0xfff;
    570577
    571578        cucul_set_dither_palette(dither, red, green, blue, alpha);
    572579
    573580        /* Draw circles */
    574         x = cos(0.07 * frame + 5.0) * 128.0 + (XSIZ / 2);
     581        x = cos(d[0] * (frame + 1000)) * 128.0 + (XSIZ / 2);
    575582        y = sin(0.11 * frame) * 128.0 + (YSIZ / 2);
    576583        put_disc(screen, x, y);
    577584
    578585        x = cos(0.13 * frame + 2.0) * 64.0 + (XSIZ / 2);
    579         y = sin(0.09 * frame + 1.0) * 64.0 + (YSIZ / 2);
     586        y = sin(d[1] * (frame + 2000)) * 64.0 + (YSIZ / 2);
    580587        put_disc(screen, x, y);
    581588        break;
Note: See TracChangeset for help on using the changeset viewer.