-
-
Save timo/47faa5c04b41c88a729aaa64fcc2aca8 to your computer and use it in GitHub Desktop.
This file contains 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
sub rot($n, int $x is rw, int $y is rw, $rx, $ry) { | |
if $ry == 0 { | |
if $rx == 1 { | |
$x = $n - 1 - $x; | |
$x = $n - 1 - $y; | |
} | |
my int $t = $x; | |
$x = $y; | |
$y = $t; | |
} | |
} | |
sub d2xy($n, $d, int $x is rw, int $y is rw) { | |
my $t = $d; | |
$x = 0; | |
$y = 0; | |
for 1, 2, 4 ... $n -> int $s { | |
my $rx = 1 +& ($t div 2); | |
my $ry = 1 & ($t +^ $rx); | |
rot($s, $x, $y, $rx, $ry); | |
$x += $s * $rx; | |
$y += $s * $ry; | |
$t div= 4; | |
} | |
} | |
sub frame($_, $t, $dt) { | |
.rgb(1, 0.75, 0.1); | |
my int $x; | |
my int $y; | |
for ^128 { | |
d2xy(8, $_, $x, $y); | |
.line_to($x, $y); | |
} | |
.stroke(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment