Home | History | Annotate | Download | only in skin

Lines Matching refs:ball

165     VectorRec       axes[3];  /* current ball axes */
198 * ACC_THRESHOLD is used to filter small ball movements out.
200 * constant, then no corresponding ball event will be sent to the
204 * the corresponding ball motion vector.
210 trackball_init( TrackBall ball, int diameter, int ring,
216 memset( ball, 0, sizeof(*ball) );
218 ball->acc_threshold = ACC_THRESHOLD;
219 ball->acc_scale = ACC_SCALE;
222 ball->diameter = diameter2;
223 ball->ball_color = ball_color;
224 ball->dot_color = dot_color;
225 ball->ring_color = ring_color;
227 ball->rotation = SKIN_ROTATION_0;
229 ball->pixels = (unsigned*)calloc( diameter2*diameter2, sizeof(unsigned) );
230 ball->surface = sdl_surface_from_argb32( ball->pixels, diameter2, diameter2 );
233 ball->axes[0][0] = 1.; ball->axes[0][1] = 0.; ball->axes[0][2] = 0.;
234 ball->axes[1][0] = 0.; ball->axes[1][1] = 1.; ball->axes[1][2] = 0.;
235 ball->axes[2][0] = 0.; ball->axes[2][1] = 0.; ball->axes[2][2] = 1.;
293 ball->dots[nn][0] = FIX16_FROM_FLOAT(x*invlen);
294 ball->dots[nn][1] = FIX16_FROM_FLOAT(y*invlen);
295 ball->dots[nn][2] = FIX16_FROM_FLOAT(z*invlen);
311 ball->sphere_map = calloc( diameter2*diameter2, sizeof(SphereCoordRec) );
318 SphereCoord coord = &ball->sphere_map[total];
320 if (r0 <= radius) { /* ball pixel */
368 ball->sphere_count = total;
373 trackball_contains( TrackBall ball, int x, int y )
375 return ( (unsigned)(x) < (unsigned)ball->diameter &&
376 (unsigned)(y) < (unsigned)ball->diameter );
380 trackball_done( TrackBall ball )
382 free( ball->sphere_map );
383 ball->sphere_map = NULL;
384 ball->sphere_count = 0;
386 if (ball->surface) {
387 SDL_FreeSurface( ball->surface );
388 ball->surface = NULL;
391 if (ball->pixels) {
392 free( ball->pixels );
393 ball->pixels = NULL;
413 trackball_move( TrackBall ball, int dx, int dy )
418 ball->acc_x += dx;
419 ball->acc_y += dy;
421 if ( norm( ball->acc_x, ball->acc_y ) > ball->acc_threshold )
423 int ddx = ball->acc_x * ball->acc_scale;
424 int ddy = ball->acc_y * ball->acc_scale;
427 ball->acc_x = 0;
428 ball->acc_y = 0;
430 switch (ball->rotation) {
456 rotator_apply( rot, ball->axes[0] );
457 rotator_apply( rot, ball->axes[1] );
458 rotator_apply( rot, ball->axes[2] );
460 if ( ball->ticks_last == 0 )
461 ball->ticks_last = now;
462 else if ( now > ball->ticks_last + (1000/60) ) {
463 ball->ticks_last = now;
473 trackball_refresh( TrackBall ball )
475 int diameter = ball->diameter;
476 unsigned* pixels = ball->pixels;
481 SDL_LockSurface( ball->surface );
483 fixedvector_from_vector( (Fix16Vector)&faxes[0], (Vector)&ball->axes[0] );
484 fixedvector_from_vector( (Fix16Vector)&faxes[1], (Vector)&ball->axes[1] );
485 fixedvector_from_vector( (Fix16Vector)&faxes[2], (Vector)&ball->axes[2] );
487 for (nn = 0; nn < ball->sphere_count; nn++) {
488 SphereCoord coord = &ball->sphere_map[nn];
500 color = ball->ball_color;
506 d[0] = ball->dots[pp][0] - ax;
507 d[1] = ball->dots[pp][1] - ay;
508 d[2] = ball->dots[pp][2] - az;
522 color = color_blend( color, ball->dot_color, a );
527 color = color_blend( ball
536 color = ball->ring_color;
546 SDL_UnlockSurface( ball->surface );
550 trackball_draw( TrackBall ball, int x, int y, SDL_Surface* dst )
556 d.w = ball->diameter;
557 d.h = ball->diameter;
559 SDL_BlitSurface( ball->surface, NULL, dst, &d );
567 TrackBall ball;
569 ANEW0(ball);
570 trackball_init( ball,
576 return ball;
580 skin_trackball_contains( SkinTrackBall* ball, int x, int y )
582 return trackball_contains(ball, x, y);
586 skin_trackball_move( SkinTrackBall* ball, int dx, int dy )
588 return trackball_move(ball, dx, dy);
592 skin_trackball_refresh ( SkinTrackBall* ball )
594 trackball_refresh(ball);
598 skin_trackball_draw( SkinTrackBall* ball, int x, int y, SDL_Surface* dst )
600 trackball_draw(ball, x, y, dst);
604 skin_trackball_destroy ( SkinTrackBall* ball )
606 if (ball) {
607 trackball_done(ball);
608 AFREE(ball);
613 skin_trackball_rect( SkinTrackBall* ball, SDL_Rect* rect )
617 rect->w = ball->diameter;
618 rect->h = ball->diameter;
623 skin_trackball_set_rotation( SkinTrackBall* ball, SkinRotation rotation )
625 ball->rotation = rotation & 3;