Changeset 1040 for libcaca


Ignore:
Timestamp:
Sep 17, 2006, 2:11:29 AM (17 years ago)
Author:
Sam Hocevar
Message:
  • Factored the star code (vieux porc).
File:
1 edited

Legend:

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

    r1038 r1040  
    218218    float angle = (time*360)*3.14/180, x,y;
    219219    unsigned int i;
     220
    220221    switch(transition)
    221222    {
    222223        case TRANSITION_STAR:
    223224            /* Compute rotated coordinates */
    224             for(i=0;i<(sizeof(star)/sizeof(*star))/2;i++)
     225            for(i = 0; i < (sizeof(star) / sizeof(*star)) / 2; i++)
    225226            {
    226227                x = star[OFFSET_X(i)];
    227228                y = star[OFFSET_Y(i)];
    228229
    229                 star_rot[OFFSET_X(i)] = x*cos(angle) - y*sin(angle);
    230                 star_rot[OFFSET_Y(i)] = y*cos(angle) + x*sin(angle);
     230                star_rot[OFFSET_X(i)] = x * cos(angle) - y * sin(angle);
     231                star_rot[OFFSET_Y(i)] = y * cos(angle) + x * sin(angle);
    231232            }
    232233
    233             mulx*=1.8;
    234             muly*=1.8;
    235             cucul_fill_triangle(mask,
    236                                 star_rot[OFFSET_X(0)]*mulx+w2,
    237                                 star_rot[OFFSET_Y(0)]*muly+h2,
    238                                 star_rot[OFFSET_X(1)]*mulx+w2,
    239                                 star_rot[OFFSET_Y(1)]*muly+h2,
    240                                 star_rot[OFFSET_X(9)]*mulx+w2,
    241                                 star_rot[OFFSET_Y(9)]*muly+h2,
    242                                 "#");
    243             cucul_fill_triangle(mask,
    244                                 star_rot[OFFSET_X(1)]*mulx+w2,
    245                                 star_rot[OFFSET_Y(1)]*muly+h2,
    246                                 star_rot[OFFSET_X(2)]*mulx+w2,
    247                                 star_rot[OFFSET_Y(2)]*muly+h2,
    248                                 star_rot[OFFSET_X(3)]*mulx+w2,
    249                                 star_rot[OFFSET_Y(3)]*muly+h2,
    250                                 "#");
    251             cucul_fill_triangle(mask,
    252                                 star_rot[OFFSET_X(3)]*mulx+w2,
    253                                 star_rot[OFFSET_Y(3)]*muly+h2,
    254                                 star_rot[OFFSET_X(4)]*mulx+w2,
    255                                 star_rot[OFFSET_Y(4)]*muly+h2,
    256                                 star_rot[OFFSET_X(5)]*mulx+w2,
    257                                 star_rot[OFFSET_Y(5)]*muly+h2,
    258                                 "#");
    259             cucul_fill_triangle(mask,
    260                                 star_rot[OFFSET_X(5)]*mulx+w2,
    261                                 star_rot[OFFSET_Y(5)]*muly+h2,
    262                                 star_rot[OFFSET_X(6)]*mulx+w2,
    263                                 star_rot[OFFSET_Y(6)]*muly+h2,
    264                                 star_rot[OFFSET_X(7)]*mulx+w2,
    265                                 star_rot[OFFSET_Y(7)]*muly+h2,
    266                                 "#");
    267             cucul_fill_triangle(mask,
    268                                 star_rot[OFFSET_X(7)]*mulx+w2,
    269                                 star_rot[OFFSET_Y(7)]*muly+h2,
    270                                 star_rot[OFFSET_X(8)]*mulx+w2,
    271                                 star_rot[OFFSET_Y(8)]*muly+h2,
    272                                 star_rot[OFFSET_X(9)]*mulx+w2,
    273                                 star_rot[OFFSET_Y(9)]*muly+h2,
    274                                 "#");
    275             cucul_fill_triangle(mask,
    276                                 star_rot[OFFSET_X(9)]*mulx+w2,
    277                                 star_rot[OFFSET_Y(9)]*muly+h2,
    278                                 star_rot[OFFSET_X(1)]*mulx+w2,
    279                                 star_rot[OFFSET_Y(1)]*muly+h2,
    280                                 star_rot[OFFSET_X(5)]*mulx+w2,
    281                                 star_rot[OFFSET_Y(5)]*muly+h2,
    282                                 "#");
    283             cucul_fill_triangle(mask,
    284                                 star_rot[OFFSET_X(9)]*mulx+w2,
    285                                 star_rot[OFFSET_Y(9)]*muly+h2,
    286                                 star_rot[OFFSET_X(5)]*mulx+w2,
    287                                 star_rot[OFFSET_Y(5)]*muly+h2,
    288                                 star_rot[OFFSET_X(7)]*mulx+w2,
    289                                 star_rot[OFFSET_Y(7)]*muly+h2,
    290                                 "#");
    291             cucul_fill_triangle(mask,
    292                                 star_rot[OFFSET_X(1)]*mulx+w2,
    293                                 star_rot[OFFSET_Y(1)]*muly+h2,
    294                                 star_rot[OFFSET_X(3)]*mulx+w2,
    295                                 star_rot[OFFSET_Y(3)]*muly+h2,
    296                                 star_rot[OFFSET_X(5)]*mulx+w2,
    297                                 star_rot[OFFSET_Y(5)]*muly+h2,
    298                                 "#");
     234            mulx *= 1.8;
     235            muly *= 1.8;
     236
     237#define DO_TRI(a, b, c) \
     238    cucul_fill_triangle(mask, \
     239        star_rot[OFFSET_X(a)]*mulx+w2, star_rot[OFFSET_Y(a)]*muly+h2, \
     240        star_rot[OFFSET_X(b)]*mulx+w2, star_rot[OFFSET_Y(b)]*muly+h2, \
     241        star_rot[OFFSET_X(c)]*mulx+w2, star_rot[OFFSET_Y(c)]*muly+h2, "#")
     242            DO_TRI(0, 1, 9);
     243            DO_TRI(1, 2, 3);
     244            DO_TRI(3, 4, 5);
     245            DO_TRI(5, 6, 7);
     246            DO_TRI(7, 8, 9);
     247            DO_TRI(9, 1, 5);
     248            DO_TRI(9, 5, 7);
     249            DO_TRI(1, 3, 5);
    299250            break;
    300251
    301252        case TRANSITION_CIRCLE:
    302             cucul_fill_ellipse(mask,
    303                                w2,
    304                                h2,
    305                                mulx,
    306                                muly,
    307                                "#");
    308 
     253            cucul_fill_ellipse(mask, w2, h2, mulx, muly, "#");
    309254            break;
    310255
    311256    }
    312257}
    313 
    314258
    315259/* The plasma effect */
Note: See TracChangeset for help on using the changeset viewer.