our $app_rect = SDL::Rect->new( -x => 0, -y => 0, -width => $w, -height => $h );
$mask->blit( $mask->rect, $app, $app_rect );
+$app->sync;
+
my @landing;
warn 'lading ',dump(@landing);
-exit;
-
-$app->sync;
-
our $event = SDL::Event->new;
our $mouse_down = 0;
sub reset_path { @path = () }
sub curve {
+
+ my $mask_col = $mask->pixel( $path[-2], $path[-1] );
+ my $mask_hex = sprintf '%02x%02x%02x', $mask_col->r, $mask_col->g, $mask_col->b;
+ warn "mask $path[-2] $path[1] $mask_hex\n";
+
+ if ( $mask_hex eq '000000' ) { # push landing point at path end
+ foreach ( 1 .. 6 ) {
+ push @path, $landing[$_]->[0], $landing[$_]->[1];
+ }
+ }
+
if ( $#path < ( 4 * 2 - 1 ) ) { # less than 4 points
warn "path too short ", dump @path;
reset_path;
} elsif ( $type == SDL_MOUSEBUTTONUP() ) {
debug 'mouse up', $event->button_x, $event->button_y;
$mouse_down = 0;
+
curve;
} elsif ( $type == SDL_QUIT() ) {
exit;
exit if $key =~ m/^[xq]$/;
if ( $key eq 's' ) { # XXX draw curve
curve;
- } elsif ( $key eq 'backspace' ) { # XXX clean screen
+ } elsif ( $key eq 'backspace' || $key eq 'c' ) { # XXX clean screen
reset_path;
- my $rect = SDL::Rect->new( -x => 0, -y => 0, -w => $w, -h => $h );
- $app->fill( $rect, $black );
- $app->update( $rect );
+ $app->fill( $app->rect, $black );
+# $app->update( $rect );
+ $mask->blit( $mask->rect, $app, $app_rect );
+ $app->sync;
} elsif ( $key eq 'd' ) { # XXX toggle debug
$debug = ! $debug;
warn "debug $debug\n";