Browse Source

* Factored the star code (vieux porc).

tags/v0.99.beta14
Sam Hocevar sam 18 years ago
parent
commit
2f64d475ec
1 changed files with 21 additions and 77 deletions
  1. +21
    -77
      src/cacademo.c

+ 21
- 77
src/cacademo.c View File

@@ -217,101 +217,45 @@ void do_transition(cucul_canvas_t *mask, int transition, float time)
int h2 = cucul_get_canvas_height(mask) / 2; int h2 = cucul_get_canvas_height(mask) / 2;
float angle = (time*360)*3.14/180, x,y; float angle = (time*360)*3.14/180, x,y;
unsigned int i; unsigned int i;

switch(transition) switch(transition)
{ {
case TRANSITION_STAR: case TRANSITION_STAR:
/* Compute rotated coordinates */ /* Compute rotated coordinates */
for(i=0;i<(sizeof(star)/sizeof(*star))/2;i++) for(i = 0; i < (sizeof(star) / sizeof(*star)) / 2; i++)
{ {
x = star[OFFSET_X(i)]; x = star[OFFSET_X(i)];
y = star[OFFSET_Y(i)]; y = star[OFFSET_Y(i)];


star_rot[OFFSET_X(i)] = x*cos(angle) - y*sin(angle); star_rot[OFFSET_X(i)] = x * cos(angle) - y * sin(angle);
star_rot[OFFSET_Y(i)] = y*cos(angle) + x*sin(angle); star_rot[OFFSET_Y(i)] = y * cos(angle) + x * sin(angle);
} }


mulx*=1.8; mulx *= 1.8;
muly*=1.8; muly *= 1.8;
cucul_fill_triangle(mask, #define DO_TRI(a, b, c) \
star_rot[OFFSET_X(0)]*mulx+w2, cucul_fill_triangle(mask, \
star_rot[OFFSET_Y(0)]*muly+h2, star_rot[OFFSET_X(a)]*mulx+w2, star_rot[OFFSET_Y(a)]*muly+h2, \
star_rot[OFFSET_X(1)]*mulx+w2, star_rot[OFFSET_X(b)]*mulx+w2, star_rot[OFFSET_Y(b)]*muly+h2, \
star_rot[OFFSET_Y(1)]*muly+h2, star_rot[OFFSET_X(c)]*mulx+w2, star_rot[OFFSET_Y(c)]*muly+h2, "#")
star_rot[OFFSET_X(9)]*mulx+w2, DO_TRI(0, 1, 9);
star_rot[OFFSET_Y(9)]*muly+h2, DO_TRI(1, 2, 3);
"#"); DO_TRI(3, 4, 5);
cucul_fill_triangle(mask, DO_TRI(5, 6, 7);
star_rot[OFFSET_X(1)]*mulx+w2, DO_TRI(7, 8, 9);
star_rot[OFFSET_Y(1)]*muly+h2, DO_TRI(9, 1, 5);
star_rot[OFFSET_X(2)]*mulx+w2, DO_TRI(9, 5, 7);
star_rot[OFFSET_Y(2)]*muly+h2, DO_TRI(1, 3, 5);
star_rot[OFFSET_X(3)]*mulx+w2,
star_rot[OFFSET_Y(3)]*muly+h2,
"#");
cucul_fill_triangle(mask,
star_rot[OFFSET_X(3)]*mulx+w2,
star_rot[OFFSET_Y(3)]*muly+h2,
star_rot[OFFSET_X(4)]*mulx+w2,
star_rot[OFFSET_Y(4)]*muly+h2,
star_rot[OFFSET_X(5)]*mulx+w2,
star_rot[OFFSET_Y(5)]*muly+h2,
"#");
cucul_fill_triangle(mask,
star_rot[OFFSET_X(5)]*mulx+w2,
star_rot[OFFSET_Y(5)]*muly+h2,
star_rot[OFFSET_X(6)]*mulx+w2,
star_rot[OFFSET_Y(6)]*muly+h2,
star_rot[OFFSET_X(7)]*mulx+w2,
star_rot[OFFSET_Y(7)]*muly+h2,
"#");
cucul_fill_triangle(mask,
star_rot[OFFSET_X(7)]*mulx+w2,
star_rot[OFFSET_Y(7)]*muly+h2,
star_rot[OFFSET_X(8)]*mulx+w2,
star_rot[OFFSET_Y(8)]*muly+h2,
star_rot[OFFSET_X(9)]*mulx+w2,
star_rot[OFFSET_Y(9)]*muly+h2,
"#");
cucul_fill_triangle(mask,
star_rot[OFFSET_X(9)]*mulx+w2,
star_rot[OFFSET_Y(9)]*muly+h2,
star_rot[OFFSET_X(1)]*mulx+w2,
star_rot[OFFSET_Y(1)]*muly+h2,
star_rot[OFFSET_X(5)]*mulx+w2,
star_rot[OFFSET_Y(5)]*muly+h2,
"#");
cucul_fill_triangle(mask,
star_rot[OFFSET_X(9)]*mulx+w2,
star_rot[OFFSET_Y(9)]*muly+h2,
star_rot[OFFSET_X(5)]*mulx+w2,
star_rot[OFFSET_Y(5)]*muly+h2,
star_rot[OFFSET_X(7)]*mulx+w2,
star_rot[OFFSET_Y(7)]*muly+h2,
"#");
cucul_fill_triangle(mask,
star_rot[OFFSET_X(1)]*mulx+w2,
star_rot[OFFSET_Y(1)]*muly+h2,
star_rot[OFFSET_X(3)]*mulx+w2,
star_rot[OFFSET_Y(3)]*muly+h2,
star_rot[OFFSET_X(5)]*mulx+w2,
star_rot[OFFSET_Y(5)]*muly+h2,
"#");
break; break;


case TRANSITION_CIRCLE: case TRANSITION_CIRCLE:
cucul_fill_ellipse(mask, cucul_fill_ellipse(mask, w2, h2, mulx, muly, "#");
w2,
h2,
mulx,
muly,
"#");

break; break;


} }
} }



/* The plasma effect */ /* The plasma effect */
#define TABLEX (XSIZ * 2) #define TABLEX (XSIZ * 2)
#define TABLEY (YSIZ * 2) #define TABLEY (YSIZ * 2)


||||||
x
 
000:0
Loading…
Cancel
Save