Changeset 616 for libcaca/trunk/src
 Timestamp:
 Mar 15, 2006, 2:06:25 PM (14 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

libcaca/trunk/src/cacaball.c
r615 r616 50 50 float i = 10.0, j = 17.0, k = 11.0; 51 51 int p, frame = 0, pause = 0; 52 double frameOffset[360+80]; 53 double frameOffset40[360]; 54 double frameOffset80[360]; 52 55 53 56 qq = cucul_init(); … … 81 84 } 82 85 86 for(frame = 0; frame<360; frame++) { 87 frameOffset[frame] = frame * M_PI / 60; 88 frameOffset40[frame] = (frame + 40) * M_PI / 60; 89 frameOffset80[frame] = (frame + 80) * M_PI / 60; 90 } 91 92 83 93 /* Go ! */ 84 94 for(;;) … … 94 104 95 105 frame++; 106 if(frame>=360) 107 frame=0; 96 108 97 109 /* Crop the palette */ … … 99 111 { 100 112 int t1, t2, t3; 101 t1 = p < 0x40 ? 0 : p < 0xc0 ? (p  0x40) * 0x20 : 0xfff; 113 double c1 = 1.0 + sin((double)frameOffset[frame]); 114 double c2 = 1.0 + sin((double)frameOffset40[frame]); 115 double c3 = 1.0 + sin((double)frameOffset80[frame]); 116 117 118 t1 = p < 0x40 ? 0 : p < 0xc0 ? (p  0x40) * 0x20 : 0xfff; 102 119 t2 = p < 0xe0 ? 0 : (p  0xe0) * 0x80; 103 120 t3 = p < 0x40 ? p * 0x40 : 0xfff; 104 105 r[p] = (1.0 + sin((double)frame * M_PI / 60)) * t1 / 4 106 + (1.0 + sin((double)(frame + 40) * M_PI / 60)) * t2 / 4 107 + (1.0 + sin((double)(frame + 80) * M_PI / 60)) * t3 / 4; 108 g[p] = (1.0 + sin((double)frame * M_PI / 60)) * t2 / 4 109 + (1.0 + sin((double)(frame + 40) * M_PI / 60)) * t3 / 4 110 + (1.0 + sin((double)(frame + 80) * M_PI / 60)) * t1 / 4; 111 b[p] = (1.0 + sin((double)frame * M_PI / 60)) * t3 / 4 112 + (1.0 + sin((double)(frame + 40) * M_PI / 60)) * t1 / 4 113 + (1.0 + sin((double)(frame + 80) * M_PI / 60)) * t2 / 4; 114 } 121 t1/=4; t2/=4; t3/=4; 122 123 124 r[p] = c1 * t1 125 + c2 * t2 126 + c3 * t3; 127 g[p] = c1 * t2 128 + c2 * t3 129 + c3 * t1; 130 b[p] = c1 * t3 131 + c2 * t1 132 + c3 * t2; 133 } 134 115 135 116 136 /* Set the palette */
Note: See TracChangeset
for help on using the changeset viewer.