From: Martin Mares Date: Sun, 28 Oct 2007 21:12:06 +0000 (+0100) Subject: Added hints. X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=e70662831590218e52f0d6eef3f051ff997f89b8;p=anim.git Added hints. --- diff --git a/AA/Net.pm b/AA/Net.pm index d0d074a..3b17fdb 100644 --- a/AA/Net.pm +++ b/AA/Net.pm @@ -9,6 +9,7 @@ sub new($$$$) { $v->DefSet('y0', 100); $v->DefSet('h', 0); $v->DefSet('xs', ''); + $v->DefSet('hint', 0); $v->Bind('y', sub { $v->Get("y0") - 50*$v->Get("h") }); $v->{XS} = AA::Label->new("$id-label"); $v->{XS}->MultiSet( @@ -16,7 +17,10 @@ sub new($$$$) { 'y' => sub { $v->Get('y') + 80 }, 'size' => 50, 'text' => sub { $v->Get('xs') }, - 'color' => sub { $v->Get('xs') ? [1,0,0] : [1,1,1] }, + 'color' => sub { + $v->Get('hint') ? [0,1,0] : + $v->Get('xs') ? [1,0,0] : [1,1,1] + }, ); return $v; } diff --git a/a.pl b/a.pl index 48a9c04..3d8b598 100755 --- a/a.pl +++ b/a.pl @@ -41,7 +41,7 @@ for (my $i=1; $i<@v; $i++) { my $ii = $i; # need to keep a copy in the current closure $v[$i]->Bind('xs', sub { $e[$ii-1]->Get('f') - (($ii == @v-1) ? 0 : $e[$ii]->Get('f')) }); } -$v[4]->{XS}->Set('color', [0,1,0]); +$v[4]->{XS}->Set('color', [1,0,1]); sub flow($$) { my ($i,$df) = @_; @@ -53,14 +53,21 @@ sub up($) { $v[$i]->Set('h', $v[$i]->Get('h') + 1); } +sub hint($) { + my ($h) = @_; + for (my $i=0; $i<@v; $i++) { + $v[$i]->Set('hint', $i == $h); + } +} + my $scenario = [ - sub { flow(0, 5); }, + sub { flow(0, 5); hint(1); }, sub { up(1); }, - sub { flow(1, 5); }, + sub { flow(1, 5); hint(2); }, sub { up(2); }, - sub { flow(2, 5); }, + sub { flow(2, 5); hint(3); }, sub { up(3); }, - sub { flow(3, 5); }, + sub { flow(3, 5); hint(-1); }, ]; if (1) { @@ -68,45 +75,45 @@ if (1) { $e[$i]->Set('c', 5-$i); } $scenario = [ - sub { flow(0, 5); }, + sub { flow(0, 5); hint(1); }, sub { up(1); }, - sub { flow(1, 4); }, + sub { flow(1, 4); hint(2); }, sub { up(2); }, - sub { flow(2, 3); }, + sub { flow(2, 3); hint(3); }, sub { up(3); }, sub { flow(3, 2); }, sub { up(3); }, - sub { flow(2, -1); }, + sub { flow(2, -1); hint(2); }, sub { up(2); }, - sub { flow(1, -1); }, + sub { flow(1, -1); hint(1); }, sub { up(1); }, sub { up(1); }, sub { flow(1, 1); }, sub { up(1); }, sub { up(1); }, sub { up(1); }, - sub { flow(0, -1); }, + sub { flow(0, -1); hint(2); }, sub { up(2); }, - sub { flow(2, 1); }, + sub { flow(2, 1); hint(3); }, sub { up(3); }, sub { up(3); }, - sub { flow(2, -1); }, + sub { flow(2, -1); hint(2); }, sub { up(2); }, sub { up(2); }, - sub { flow(2, 1); }, + sub { flow(2, 1); hint(3); }, sub { up(3); }, sub { up(3); }, - sub { flow(2, -1); }, + sub { flow(2, -1); hint(2); }, sub { up(2); }, sub { up(2); }, sub { flow(2, 1); }, - sub { flow(1, -1); }, - sub { flow(0, -1); }, + sub { flow(1, -1); hint(1); }, + sub { flow(0, -1); hint(3); }, sub { up(3); }, sub { up(3); }, - sub { flow(2, -1); }, - sub { flow(1, -1); }, - sub { flow(0, -1); }, + sub { flow(2, -1); hint(2); }, + sub { flow(1, -1); hint(1); }, + sub { flow(0, -1); hint(-1); }, ]; }