Changeset 339


Ignore:
Timestamp:
Jan 12, 2004, 3:25:46 PM (18 years ago)
Author:
Sam Hocevar
Message:
  • examples/cacaballs.c: + Bigger metaballs, less metaballs. + Rotating palette.
  • examples/cacaplas.c: + Slightly decreased speed.
  • examples/cacacirc.c: + New effect.
Location:
libcaca/trunk/examples
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/examples

    • Property svn:ignore
      •  

        old new  
        1313cacafire
        1414cacafire.exe
         15cacacirc
         16cacacirc.exe
        1517cacaplas
        1618cacaplas.exe
  • libcaca/trunk/examples/Makefile.am

    r333 r339  
    77EXTRA_DIST = caca.txt
    88
    9 bin_PROGRAMS = cacademo cacafire cacaball cacaplas cacaview
     9bin_PROGRAMS = cacademo cacafire cacaball cacaplas cacaview cacacirc
    1010
    1111cacademo_SOURCES = demo.c
     
    2525cacaplas_CPPFLAGS = -I$(top_srcdir)/src
    2626
     27cacacirc_SOURCES = cacacirc.c
     28cacacirc_LDADD = ../src/libcaca.a @CACA_LIBS@ @MATH_LIBS@
     29cacacirc_CPPFLAGS = -I$(top_srcdir)/src
     30
    2731cacaview_SOURCES = cacaview.c
    2832cacaview_LDADD = ../src/libcaca.a @CACA_LIBS@
  • libcaca/trunk/examples/cacaball.c

    r321 r339  
    2929#include <math.h>
    3030
     31#ifndef M_PI
     32#   define M_PI 3.14159265358979323846
     33#endif
     34
    3135#include "caca.h"
    3236
     
    3640
    3741#define METASIZE 100
    38 #define METABALLS 24
     42#define METABALLS 16
    3943
    4044/* Colour index where to crop balls */
    41 #define CROPBALL 180
     45#define CROPBALL 160
    4246
    4347static void create_ball(void);
     
    5458    struct caca_bitmap *caca_bitmap;
    5559    float i = 10.0, j = 17.0, k = 11.0;
    56     int p;
     60    int p, frame = 0;
    5761
    5862    if(caca_init())
    5963        return 1;
    6064
    61     caca_set_delay(10000);
     65    caca_set_delay(20000);
    6266
    6367    /* Make the palette eatable by libcaca */
    6468    for(p = 0; p < 256; p++)
    65     {
    66         r[p] = p < 0x40 ? 0 : p < 0xc0 ? (p - 0x40) * 0x20 : 0xfff;
    67         g[p] = p < 0xc0 ? 0 : (p - 0xc0) * 0x40;
    68         b[p] = p < 0x40 ? p * 0x40 : 0xfff;
    69         a[p] = 0x0;
    70     }
    71 
    72     /* Crop the palette */
    73     for(p = 0; p < CROPBALL; p++)
    7469        r[p] = g[p] = b[p] = a[p] = 0x0;
     70    r[255] = g[255] = b[255] = 0xfff;
    7571
    7672    /* Create a libcaca bitmap smaller than our pixel buffer, so that we
     
    7874    caca_bitmap = caca_create_bitmap(8, XSIZ - METASIZE, YSIZ - METASIZE,
    7975                                     XSIZ, 0, 0, 0, 0);
    80 
    81     /* Set the palette */
    82     caca_set_bitmap_palette(caca_bitmap, r, g, b, a);
    8376
    8477    /* Generate ball sprite */
     
    9689    while(!caca_get_event(CACA_EVENT_KEY_PRESS))
    9790    {
     91        frame++;
     92
     93        /* Crop the palette */
     94        for(p = CROPBALL; p < 255; p++)
     95        {
     96            int t1, t2, t3;
     97            t1 = p < 0x40 ? 0 : p < 0xc0 ? (p - 0x40) * 0x20 : 0xfff;
     98            t2 = p < 0xe0 ? 0 : (p - 0xe0) * 0x80;
     99            t3 = p < 0x40 ? p * 0x40 : 0xfff;
     100
     101            r[p] = (1.0 + sin((double)frame * M_PI / 60)) * t1 / 4
     102                 + (1.0 + sin((double)(frame + 40) * M_PI / 60)) * t2 / 4
     103                 + (1.0 + sin((double)(frame + 80) * M_PI / 60)) * t3 / 4;
     104            g[p] = (1.0 + sin((double)frame * M_PI / 60)) * t2 / 4
     105                 + (1.0 + sin((double)(frame + 40) * M_PI / 60)) * t3 / 4
     106                 + (1.0 + sin((double)(frame + 80) * M_PI / 60)) * t1 / 4;
     107            b[p] = (1.0 + sin((double)frame * M_PI / 60)) * t3 / 4
     108                 + (1.0 + sin((double)(frame + 40) * M_PI / 60)) * t1 / 4
     109                 + (1.0 + sin((double)(frame + 80) * M_PI / 60)) * t2 / 4;
     110        }
     111
     112        /* Set the palette */
     113        caca_set_bitmap_palette(caca_bitmap, r, g, b, a);
     114
    98115        /* Silly paths for our balls */
    99116        for(p = 0; p < METABALLS; p++)
  • libcaca/trunk/examples/cacaplas.c

    r334 r339  
    5656        return 1;
    5757
    58     caca_set_delay(10000);
     58    caca_set_delay(20000);
    5959
    6060    /* Fill various tables */
Note: See TracChangeset for help on using the changeset viewer.