generate less curve points
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 19 May 2010 16:12:10 +0000 (18:12 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 19 May 2010 16:12:10 +0000 (18:12 +0200)
trace-path.pl

index 5f9884a..ed1c237 100755 (executable)
@@ -44,12 +44,12 @@ our $black = SDL::Color->new( 0x00, 0x00, 0x00 );
 
 my ( $last_x, $last_y ) = ( 0,0 );
 
 
 my ( $last_x, $last_y ) = ( 0,0 );
 
-my @path;
+our @path;
 
 sub curve {
        return unless $#path > 4;
        my $curve = Math::CatmullRom->new( splice @path, 0, $#path + $#path / 2 );
 
 sub curve {
        return unless $#path > 4;
        my $curve = Math::CatmullRom->new( splice @path, 0, $#path + $#path / 2 );
-       my @curve = $curve->curve( $mouse_trashold * $max_path_length / 2 );
+       my @curve = $curve->curve( $mouse_trashold * 10 );
        debug 'curve' => @curve;
 
        my $i = 0;
        debug 'curve' => @curve;
 
        my $i = 0;
@@ -101,7 +101,7 @@ sub handle_events {
                        if ( $mouse_down && ( $dx > $mouse_trashold || $dy > $mouse_trashold ) ) {
                                if ( $#path < $max_path_length ) {
                                        push @path, $x, $y;
                        if ( $mouse_down && ( $dx > $mouse_trashold || $dy > $mouse_trashold ) ) {
                                if ( $#path < $max_path_length ) {
                                        push @path, $x, $y;
-                                       my $rect = SDL::Rect->new( -x => $event->motion_x, -y => $event->motion_y, -w => 3, -h => 3 );
+                                       my $rect = SDL::Rect->new( -x => $event->motion_x - 1, -y => $event->motion_y -1 , -w => 3, -h => 3 );
                                        $app->fill( $rect, $white );
                                        $app->update( $rect );
                                        $last_x = $x;
                                        $app->fill( $rect, $white );
                                        $app->update( $rect );
                                        $last_x = $x;