Vibrating rectangles: Difference between revisions

Content added Content deleted
m (was missing first 3 lines of program)
m (→‎{{header|Perl 6}}: minor twiddles)
Line 63: Line 63:
my %r = :tl<┌>, :h<─>, :tr<┐>, :v<│>, :bl<└>, :br<┘>;
my %r = :tl<┌>, :h<─>, :tr<┐>, :v<│>, :bl<└>, :br<┘>;


my %colors = rd => "\e[1;31m", gn => "\e[1;32m", yw => "\e[1;33m",
my @colors = « \e[1;31m \e[1;94m \e[1;33m \e[1;35m \e[1;36m \e[1;32m \e[1;34m »;
bu => "\e[1;34m", mg => "\e[1;35m", cy => "\e[1;36m";


# color palette
# color palette
my @c = flat %colors<rd> xx 12, %colors<bu> xx 12, %colors<yw> xx 12;
my @c = flat @colors[0] xx 12, @colors[3] xx 12, @colors[2] xx 12;

my @vibe;

rect($_, 31-$_) for 0..15;


print "\e[?25l"; # hide the cursor
print "\e[?25l"; # hide the cursor
Line 81: Line 76:


my $rot = 1;
my $rot = 1;

my @vibe;


loop {
loop {
rect($_, 31-$_) for ^15;
display @vibe;
display @vibe;
@c.=rotate($rot);
@c.=rotate($rot);
if ++$ %% 30 {
if ++$ %% 30 {
@c = |%colors.values.roll(3);
@c = |@colors.pick(3);
@c = sort(flat @c xx 12);
@c = sort(flat @c xx 12);
$rot *= -1;
$rot *= -1;
}
}
rect($_, 31-$_) for 0..15;
sleep .1;
sleep .1;
}
}