From f374b4039469b074bc0034ed47076d432e6a9582 Mon Sep 17 00:00:00 2001 From: maemo Date: Sun, 27 Sep 2009 17:18:01 +0100 Subject: [PATCH] small fix to pupil coordinate calculation --- src/eyes.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/eyes.c b/src/eyes.c index a735b92..d213234 100644 --- a/src/eyes.c +++ b/src/eyes.c @@ -81,13 +81,6 @@ calculate_pupil_xy (EyesPluginContent *eyes_applet, h = hypot (nx, ny); - if ( nx*nx/((eyes_applet->eye_width/2.0 - eyes_applet->pupil_width / 2)*(eyes_applet->eye_width/2.0 - eyes_applet->pupil_width/2)) + ny*ny/((eyes_applet->eye_height/2 - eyes_applet->pupil_height/2)*(eyes_applet->eye_height/2 - eyes_applet->pupil_height/2)) < 1 ) - { - *pupil_x = nx + eyes_applet->eye_width / 2; - *pupil_y = ny + eyes_applet->eye_height / 2; - return; - } - sina = nx / h; cosa = ny / h; @@ -95,8 +88,16 @@ calculate_pupil_xy (EyesPluginContent *eyes_applet, temp -= hypot ((eyes_applet->pupil_width / 2) * sina, (eyes_applet->pupil_height / 2) * cosa); temp -= hypot ((eyes_applet->wall_thickness / 2) * sina, (eyes_applet->wall_thickness / 2) * cosa); - *pupil_x = temp * sina + (eyes_applet->eye_width / 2); - *pupil_y = temp * cosa + (eyes_applet->eye_height / 2); + if ( hypot(temp*sina, temp*cosa) > hypot( nx , ny ) ) + { + *pupil_x = nx + eyes_applet->eye_width / 2; + *pupil_y = ny + eyes_applet->eye_height / 2; + } + else + { + *pupil_x = temp * sina + (eyes_applet->eye_width / 2); + *pupil_y = temp * cosa + (eyes_applet->eye_height / 2); + } } static void -- 1.7.9.5