libcaca  0.99.beta19
About: libcaca is a graphics library that outputs text instead of pixels, so that it can work on older video cards or text terminals (something like an advanced AAlib library).
  Fossies Dox: libcaca-0.99.beta19.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

cacademo.c File Reference
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "caca.h"
#include "texture.h"
Include dependency graph for cacademo.c:

Go to the source code of this file.

Macros

#define M_PI   3.14159265358979323846
 
#define DEMOS   (sizeof(fn)/sizeof(*fn))
 
#define DEMO_FRAMES   caca_rand(500, 1000)
 
#define TRANSITION_FRAMES   40
 
#define TRANSITION_COUNT   5
 
#define TRANSITION_CIRCLE   0
 
#define TRANSITION_STAR   1
 
#define TRANSITION_SQUARE   2
 
#define TRANSITION_VLINES   3
 
#define TRANSITION_HLINES   4
 
#define XSIZ   256
 
#define YSIZ   256
 
#define DO_TRI(a, b, c)
 
#define TABLEX   (XSIZ * 2)
 
#define TABLEY   (YSIZ * 2)
 
#define METASIZE   (XSIZ/2)
 
#define METABALLS   12
 
#define CROPBALL   200 /* Colour index where to crop balls */
 
#define DISCSIZ   (XSIZ*2)
 
#define DISCTHICKNESS   (XSIZ*15/40)
 
#define ANTS   15
 
#define ITER   2
 
#define MAXDROPS   500
 
#define MINLEN   15
 
#define MAXLEN   30
 
#define TEXTURE_SIZE   256
 
#define TABLE_SIZE   65536
 
#define PRECISION   8
 
#define FMUL(a, b)   (((a)*(b))>>PRECISION)
 
#define TOFIX(d)   ((int)( (d)*(double)(1<<PRECISION) ))
 
#define TOINT(a)   (a>>PRECISION);
 

Enumerations

enum  action {
  PREPARE, INIT, UPDATE, RENDER,
  FREE
}
 

Functions

void transition (caca_canvas_t *, int, int)
 
void plasma (enum action, caca_canvas_t *)
 
void metaballs (enum action, caca_canvas_t *)
 
void moire (enum action, caca_canvas_t *)
 
void langton (enum action, caca_canvas_t *)
 
void matrix (enum action, caca_canvas_t *)
 
void rotozoom (enum action, caca_canvas_t *)
 
int main (int argc, char **argv)
 
static void do_plasma (uint8_t *, double, double, double, double, double, double)
 
static void create_ball (void)
 
static void draw_ball (uint8_t *, unsigned int, unsigned int)
 
static void put_disc (uint8_t *, int, int)
 
static void draw_line (int, int, char)
 

Variables

void(* fn [])(enum action, caca_canvas_t *)
 
static int frame = 0
 
static uint8_t table [(256 *2) *(256 *2)]
 
static uint8_t metaball [(256/2) *(256/2)]
 
static uint8_t disc [(256 *2) *(256 *2)]
 

Macro Definition Documentation

◆ ANTS

#define ANTS   15

Definition at line 684 of file cacademo.c.

◆ CROPBALL

#define CROPBALL   200 /* Colour index where to crop balls */

Definition at line 419 of file cacademo.c.

◆ DEMO_FRAMES

#define DEMO_FRAMES   caca_rand(500, 1000)

Definition at line 50 of file cacademo.c.

◆ DEMOS

#define DEMOS   (sizeof(fn)/sizeof(*fn))

Definition at line 48 of file cacademo.c.

◆ DISCSIZ

#define DISCSIZ   (XSIZ*2)

Definition at line 569 of file cacademo.c.

◆ DISCTHICKNESS

#define DISCTHICKNESS   (XSIZ*15/40)

Definition at line 570 of file cacademo.c.

◆ DO_TRI

#define DO_TRI (   a,
  b,
 
)
Value:
star_rot[(a)*2] * mulx + w2, star_rot[(a)*2+1] * muly + h2, \
star_rot[(b)*2] * mulx + w2, star_rot[(b)*2+1] * muly + h2, \
star_rot[(c)*2] * mulx + w2, star_rot[(c)*2+1] * muly + h2, '#')

◆ FMUL

#define FMUL (   a,
 
)    (((a)*(b))>>PRECISION)

Definition at line 865 of file cacademo.c.

◆ ITER

#define ITER   2

Definition at line 685 of file cacademo.c.

◆ M_PI

#define M_PI   3.14159265358979323846

Definition at line 23 of file cacademo.c.

◆ MAXDROPS

#define MAXDROPS   500

Definition at line 772 of file cacademo.c.

◆ MAXLEN

#define MAXLEN   30

Definition at line 774 of file cacademo.c.

◆ METABALLS

#define METABALLS   12

Definition at line 418 of file cacademo.c.

◆ METASIZE

#define METASIZE   (XSIZ/2)

Definition at line 417 of file cacademo.c.

◆ MINLEN

#define MINLEN   15

Definition at line 773 of file cacademo.c.

◆ PRECISION

#define PRECISION   8

Definition at line 863 of file cacademo.c.

◆ TABLE_SIZE

#define TABLE_SIZE   65536

Definition at line 860 of file cacademo.c.

◆ TABLEX

#define TABLEX   (XSIZ * 2)

Definition at line 311 of file cacademo.c.

◆ TABLEY

#define TABLEY   (YSIZ * 2)

Definition at line 312 of file cacademo.c.

◆ TEXTURE_SIZE

#define TEXTURE_SIZE   256

Definition at line 859 of file cacademo.c.

◆ TOFIX

#define TOFIX (   d)    ((int)( (d)*(double)(1<<PRECISION) ))

Definition at line 866 of file cacademo.c.

◆ TOINT

#define TOINT (   a)    (a>>PRECISION);

Definition at line 867 of file cacademo.c.

◆ TRANSITION_CIRCLE

#define TRANSITION_CIRCLE   0

Definition at line 54 of file cacademo.c.

◆ TRANSITION_COUNT

#define TRANSITION_COUNT   5

Definition at line 53 of file cacademo.c.

◆ TRANSITION_FRAMES

#define TRANSITION_FRAMES   40

Definition at line 51 of file cacademo.c.

◆ TRANSITION_HLINES

#define TRANSITION_HLINES   4

Definition at line 58 of file cacademo.c.

◆ TRANSITION_SQUARE

#define TRANSITION_SQUARE   2

Definition at line 56 of file cacademo.c.

◆ TRANSITION_STAR

#define TRANSITION_STAR   1

Definition at line 55 of file cacademo.c.

◆ TRANSITION_VLINES

#define TRANSITION_VLINES   3

Definition at line 57 of file cacademo.c.

◆ XSIZ

#define XSIZ   256

Definition at line 61 of file cacademo.c.

◆ YSIZ

#define YSIZ   256

Definition at line 62 of file cacademo.c.

Enumeration Type Documentation

◆ action

enum action
Enumerator
PREPARE 
INIT 
UPDATE 
RENDER 
FREE 

Definition at line 29 of file cacademo.c.

Function Documentation

◆ create_ball()

static void create_ball ( void  )
static

Definition at line 529 of file cacademo.c.

References distance(), metaball, METASIZE, x, and y.

Referenced by metaballs().

◆ do_plasma()

static void do_plasma ( uint8_t *  pixels,
double  x_1,
double  y_1,
double  x_2,
double  y_2,
double  x_3,
double  y_3 
)
static

Definition at line 392 of file cacademo.c.

References table, TABLEX, TABLEY, x, XSIZ, y, and YSIZ.

Referenced by plasma().

◆ draw_ball()

static void draw_ball ( uint8_t *  screen,
unsigned int  bx,
unsigned int  by 
)
static

Definition at line 544 of file cacademo.c.

References metaball, METASIZE, and XSIZ.

Referenced by metaballs().

◆ draw_line()

static void draw_line ( int  x,
int  y,
char  color 
)
static

Definition at line 669 of file cacademo.c.

References disc, DISCSIZ, x, and y.

Referenced by moire().

◆ langton()

◆ main()

◆ matrix()

◆ metaballs()

◆ moire()

◆ plasma()

◆ put_disc()

static void put_disc ( uint8_t *  screen,
int  x,
int  y 
)
static

Definition at line 657 of file cacademo.c.

References disc, DISCSIZ, x, XSIZ, y, and YSIZ.

Referenced by moire().

◆ rotozoom()

◆ transition()

void transition ( caca_canvas_t mask,
int  tmode,
int  completed 
)

Variable Documentation

◆ disc

uint8_t disc[(256 *2) *(256 *2)]
static

Definition at line 571 of file cacademo.c.

Referenced by draw_line(), and put_disc().

◆ fn

void(* fn[])(enum action, caca_canvas_t *)
Initial value:

Definition at line 39 of file cacademo.c.

Referenced by main().

◆ frame

int frame = 0
static

Definition at line 65 of file cacademo.c.

Referenced by main(), metaballs(), moire(), and plasma().

◆ metaball

uint8_t metaball[(256/2) *(256/2)]
static

Definition at line 420 of file cacademo.c.

Referenced by create_ball(), and draw_ball().

◆ table

uint8_t table[(256 *2) *(256 *2)]
static

Definition at line 313 of file cacademo.c.

Referenced by do_plasma(), and plasma().

metaballs
void metaballs(enum action, caca_canvas_t *)
Definition: cacademo.c:425
matrix
void matrix(enum action, caca_canvas_t *)
Definition: cacademo.c:776
plasma
void plasma(enum action, caca_canvas_t *)
Definition: cacademo.c:318
caca_fill_triangle
#define caca_fill_triangle(x, y, z, t, u, v, c)
Definition: caca0.h:177
rotozoom
void rotozoom(enum action, caca_canvas_t *)
Definition: cacademo.c:871
moire
void moire(enum action, caca_canvas_t *)
Definition: cacademo.c:576