|
|
Line 15: |
Line 15: |
|
[https://github.com/thundergnat/rc/blob/master/img/fountain-raku.mp4?raw=true Off-site link to a demo video] |
|
[https://github.com/thundergnat/rc/blob/master/img/fountain-raku.mp4?raw=true Off-site link to a demo video] |
|
|
|
|
|
⚫ |
|
|
⚫ |
<lang perl>#!/usr/bin/perl |
|
|
|
|
⚫ |
use strict; # https://rosettacode.org/wiki/Particle_fountain |
|
⚫ |
|
|
⚫ |
|
|
|
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
my @colors = qw( red green blue yellow cyan magenta orange white ); |
|
|
|
|
⚫ |
my $mw = MainWindow->new; |
|
⚫ |
my $c = $mw->Canvas( -width => $size, -height => $size, -bg => 'black', |
|
⚫ |
|
|
⚫ |
$mw->Button(-text => 'Exit', -command => sub {$mw->destroy}, |
|
⚫ |
|
|
|
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
|
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
$c->createLine($size / 2 - 10, $size, $size / 2, $size - 10, |
|
⚫ |
$size / 2 + 10, $size, -fill => 'white' ); |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
my ($ox, $oy, $vx, $vy, $color) = @$_; |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
$c->createRectangle($ox, $oy, $x, $y, -fill => $color, -outline => $color); |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
$_->[3] += 0.006; # gravity :) |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
@particles = grep defined, @particles; |
|
⚫ |
if( @particles < $maxparticles and --$| ) |
|
⚫ |
|
|
⚫ |
push @particles, [ $size >> 1, $size - 10, |
|
⚫ |
(1 - rand 2) / 2.5 , -3 - rand 0.05, $colors[rand @colors] ]; |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
|
|
|
=={{header|Phix}}== |
|
=={{header|Phix}}== |
|
{{trans|Raku}} |
|
{{trans|Raku}} |
Line 169: |
Line 219: |
|
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span> |
|
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span> |
|
<!--</lang>--> |
|
<!--</lang>--> |
|
|
|
⚫ |
|
|
⚫ |
<lang perl>#!/usr/bin/perl |
|
|
|
|
⚫ |
use strict; # https://rosettacode.org/wiki/Particle_fountain |
|
⚫ |
|
|
⚫ |
|
|
|
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
my @colors = qw( red green blue yellow cyan magenta orange white ); |
|
|
|
|
⚫ |
my $mw = MainWindow->new; |
|
⚫ |
my $c = $mw->Canvas( -width => $size, -height => $size, -bg => 'black', |
|
⚫ |
|
|
⚫ |
$mw->Button(-text => 'Exit', -command => sub {$mw->destroy}, |
|
⚫ |
|
|
|
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
|
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
$c->createLine($size / 2 - 10, $size, $size / 2, $size - 10, |
|
⚫ |
$size / 2 + 10, $size, -fill => 'white' ); |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
my ($ox, $oy, $vx, $vy, $color) = @$_; |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
$c->createRectangle($ox, $oy, $x, $y, -fill => $color, -outline => $color); |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
$_->[3] += 0.006; # gravity :) |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
@particles = grep defined, @particles; |
|
⚫ |
if( @particles < $maxparticles and --$| ) |
|
⚫ |
|
|
⚫ |
push @particles, [ $size >> 1, $size - 10, |
|
⚫ |
(1 - rand 2) / 2.5 , -3 - rand 0.05, $colors[rand @colors] ]; |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
|
|
|
|
|
=={{header|Raku}}== |
|
=={{header|Raku}}== |