Last active
August 29, 2015 16:54
-
-
Save skids/d804af84ed6122ba4a53 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my sub build-cursor-to-template { | |
my ($x,$y) = 13,13; | |
my $raw = qq:x{ tput cup $y $x }; | |
my Str sub cursor-template( Int :$x, Int :$y ) { | |
# there may be single digit numbers in the escape preamble | |
$raw ~~ s:nth(*-1)[\d+] = $y+1; | |
$raw ~~ s:nth(*)[\d+] = $x+1; | |
return $raw; | |
} | |
return &cursor-template; | |
} | |
my &templ = build-cursor-to-template; | |
templ(:0x,:0y).substr(1).say; | |
templ(:1x,:1y).substr(1).say; | |
templ(:80x,:25y).substr(1).say; | |
templ(:300x,:300y).substr(1).say; | |
templ(:9001x,:9001y).substr(1).say; | |
=finish | |
[1;1H | |
[2;2H | |
[26;81H | |
[301;301H | |
[9002;9002H | |
diff --git a/lib/Terminal/Print/Element/Grid.pm6 b/lib/Terminal/Print/Element/Grid.pm6 | |
index c36bbbf..d95dcec 100644 | |
--- a/lib/Terminal/Print/Element/Grid.pm6 | |
+++ b/lib/Terminal/Print/Element/Grid.pm6 | |
@@ -22,7 +22,7 @@ has $!grid-string; | |
method new( :$max-columns, :$max-rows ) { | |
my @column-range = ^$max-columns; | |
my @row-range = ^$max-rows; | |
- my @grid-indices = (@column-range X @row-range).map({ [$^x, $^y] }); | |
+ my @grid-indices = (@column-range X @row-range).flat.map({ [$^x, $^y] }); | |
my (@grid, @buffer); | |
for @column-range -> $x { | |
diff --git a/examples/show-love.p6 b/examples/show-love.p6 | |
index a15f69b..6e899f2 100644 | |
--- a/examples/show-love.p6 | |
+++ b/examples/show-love.p6 | |
@@ -11,7 +11,7 @@ for $b.grid-indices -> [$x,$y] { | |
if $x %% 3 { | |
# $b[$x][$y] = colored('♥', @colors.roll); | |
$b[$x][$y] ='♥'; | |
- push @hearts, [$x,$y]; | |
+ @hearts.push($[$x,$y]); | |
} | |
} | |
@@ -19,7 +19,8 @@ for $b.grid-indices -> [$x,$y] { | |
for @hearts.pick( +@hearts ) -> [$x,$y] { | |
$b[$x][$y].print-cell; | |
my $range = ^0.010; | |
- sleep 0.05 + $range.pick; # longer hug | |
+# XXX $range.pick is not quite working this way, not sure if it should even. | |
+ sleep 0.05; # + $range.pick; # longer hug | |
} | |
sleep 5; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment