App-Physics-ParticleMotion
view release on metacpan or search on metacpan
lib/App/Physics/ParticleMotion.pm view on Meta::CPAN
my $dt = 0.1;
# @prevlines holds line objects from the previous iterations.
my @prevlines = ();
# Previous values for line drawing
my @prev_x = ();
my @prev_y = ();
# Start time of the simulation for speed adjustment on fast systems
my $timeref = time();
# main loop
while (1) {
# Delete old lines if we don't want to keep traces.
# Change their color otherwise
if ( not $trace ) {
$cloth->delete($_) foreach @prevlines;
@prevlines = ();
}
lib/App/Physics/ParticleMotion.pm view on Meta::CPAN
-disabledfill => $particles[$p_no]{colort},
);
push @prevlines, $line; # if not $trace;
}
$prev_x[$p_no] = $x;
$prev_y[$p_no] = $y;
}
# Speed control.
DoOneEvent(DONT_WAIT);
my $endtime = $timeref + $t / $time_warp;
while ( $endtime > time() ) {
sleep(0.01);
DoOneEvent(DONT_WAIT);
}
}
}
( run in 1.016 second using v1.01-cache-2.11-cpan-49f99fa48dc )