Home | History | Annotate | Download | only in skin

Lines Matching defs:ball

164     VectorRec       axes[3];  /* current ball axes */
197 * ACC_THRESHOLD is used to filter small ball movements out.
199 * constant, then no corresponding ball event will be sent to the
203 * the corresponding ball motion vector.
209 trackball_init( TrackBall ball, int diameter, int ring,
215 memset( ball, 0, sizeof(*ball) );
217 ball->acc_threshold = ACC_THRESHOLD;
218 ball->acc_scale = ACC_SCALE;
221 ball->diameter = diameter2;
222 ball->ball_color = ball_color;
223 ball->dot_color = dot_color;
224 ball->ring_color = ring_color;
226 ball->rotation = SKIN_ROTATION_0;
228 ball->pixels = (unsigned*)calloc( diameter2*diameter2, sizeof(unsigned) );
229 ball->surface = sdl_surface_from_argb32( ball->pixels, diameter2, diameter2 );
232 ball->axes[0][0] = 1.; ball->axes[0][1] = 0.; ball->axes[0][2] = 0.;
233 ball->axes[1][0] = 0.; ball->axes[1][1] = 1.; ball->axes[1][2] = 0.;
234 ball->axes[2][0] = 0.; ball->axes[2][1] = 0.; ball->axes[2][2] = 1.;
292 ball->dots[nn][0] = FIX16_FROM_FLOAT(x*invlen);
293 ball->dots[nn][1] = FIX16_FROM_FLOAT(y*invlen);
294 ball->dots[nn][2] = FIX16_FROM_FLOAT(z*invlen);
310 ball->sphere_map = calloc( diameter2*diameter2, sizeof(SphereCoordRec) );
317 SphereCoord coord = &ball->sphere_map[total];
319 if (r0 <= radius) { /* ball pixel */
367 ball->sphere_count = total;
372 trackball_contains( TrackBall ball, int x, int y )
374 return ( (unsigned)(x) < (unsigned)ball->diameter &&
375 (unsigned)(y) < (unsigned)ball->diameter );
379 trackball_done( TrackBall ball )
381 free( ball->sphere_map );
382 ball->sphere_map = NULL;
383 ball->sphere_count = 0;
385 if (ball->surface) {
386 SDL_FreeSurface( ball->surface );
387 ball->surface = NULL;
390 if (ball->pixels) {
391 free( ball->pixels );
392 ball->pixels = NULL;
412 trackball_move( TrackBall ball, int dx, int dy )
417 ball->acc_x += dx;
418 ball->acc_y += dy;
420 if ( norm( ball->acc_x, ball->acc_y ) > ball->acc_threshold )
422 int ddx = ball->acc_x * ball->acc_scale;
423 int ddy = ball->acc_y * ball->acc_scale;
426 ball->acc_x = 0;
427 ball->acc_y = 0;
429 switch (ball->rotation) {
455 rotator_apply( rot, ball->axes[0] );
456 rotator_apply( rot, ball->axes[1] );
457 rotator_apply( rot, ball->axes[2] );
459 if ( ball->ticks_last == 0 )
460 ball->ticks_last = now;
461 else if ( now > ball->ticks_last + (1000/60) ) {
462 ball->ticks_last = now;
472 trackball_refresh( TrackBall ball )
474 int diameter = ball->diameter;
475 unsigned* pixels = ball->pixels;
480 SDL_LockSurface( ball->surface );
482 fixedvector_from_vector( (Fix16Vector)&faxes[0], (Vector)&ball->axes[0] );
483 fixedvector_from_vector( (Fix16Vector)&faxes[1], (Vector)&ball->axes[1] );
484 fixedvector_from_vector( (Fix16Vector)&faxes[2], (Vector)&ball->axes[2] );
486 for (nn = 0; nn < ball->sphere_count; nn++) {
487 SphereCoord coord = &ball->sphere_map[nn];
499 color = ball->ball_color;
505 d[0] = ball->dots[pp][0] - ax;
506 d[1] = ball->dots[pp][1] - ay;
507 d[2] = ball->dots[pp][2] - az;
521 color = color_blend( color, ball->dot_color, a );
526 color = color_blend( ball->ring_color, color, a );
535 color = ball->ring_color;
545 SDL_UnlockSurface( ball->surface );
549 trackball_draw( TrackBall ball, int x, int y, SDL_Surface* dst )
555 d.w = ball->diameter;
556 d.h = ball->diameter;
558 SDL_BlitSurface( ball->surface, NULL, dst, &d );
566 TrackBall ball;
568 ANEW0(ball);
569 trackball_init( ball,
575 return ball;
579 skin_trackball_contains( SkinTrackBall* ball, int x, int y )
581 return trackball_contains(ball, x, y);
585 skin_trackball_move( SkinTrackBall* ball, int dx, int dy )
587 return trackball_move(ball, dx, dy);
591 skin_trackball_refresh ( SkinTrackBall* ball )
593 trackball_refresh(ball);
597 skin_trackball_draw( SkinTrackBall* ball, int x, int y, SDL_Surface* dst )
599 trackball_draw(ball, x, y, dst);
603 skin_trackball_destroy ( SkinTrackBall* ball )
605 if (ball) {
606 trackball_done(ball);
607 AFREE(ball);
612 skin_trackball_rect( SkinTrackBall* ball, SDL_Rect* rect )
616 rect->w = ball->diameter;
617 rect->h = ball->diameter;
622 skin_trackball_set_rotation( SkinTrackBall* ball, SkinRotation rotation )
624 ball->rotation = rotation & 3;