Marching squares: Difference between revisions
Content added Content deleted
m (→{{header|Raku}}: insignificant changes) |
SqrtNegInf (talk | contribs) m (→{{header|Raku}}: small simplifications) |
||
Line 338: | Line 338: | ||
for ^width X ^height -> (\x,\y) { |
for ^width X ^height -> (\x,\y) { |
||
if data[y;x] { |
|||
my ($cx,$cy,$directions,$previous) = x, y; |
my ($cx,$cy,$directions,$previous) = x, y; |
||
repeat { |
repeat { |
||
my $mask |
my $mask; |
||
for (0,0,1),(1,0,2),(0,1,4),(1,1,8) -> (\dx,\dy,\b) { |
for (0,0,1),(1,0,2),(0,1,4),(1,1,8) -> (\dx,\dy,\b) { |
||
my ($mx,$my) = $cx+dx,$cy+dy; |
my ($mx,$my) = $cx+dx,$cy+dy; |
||
$mask += b if |
$mask += b if all $mx>1, $my>1, data[$my-1;$mx-1] |
||
} |
} |
||
given do given $mask { |
given do given $mask { |
||
Line 355: | Line 355: | ||
} { |
} { |
||
$directions ~= $previous = $_ ; |
$directions ~= $previous = $_ ; |
||
($cx,$cy) <<+=<< |
($cx,$cy) <<+=<< (@dx[.value], @dy[.value]) |
||
} |
} |
||
} until $cx==x and $cy==y ; |
} until $cx==x and $cy==y ; |