YAPC::EU 2018 Glasgow Update!
This commit is contained in:
parent
22f33d4004
commit
4e2d22a71d
1170 changed files with 15042 additions and 3047 deletions
7
Task/Dragon-curve/Befunge/dragon-curve.bf
Normal file
7
Task/Dragon-curve/Befunge/dragon-curve.bf
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
" :htpeD">:#,_&>:00p:2%10p:2/:1+1>\#<1#*-#2:#\_$:1-20p510g2*-*1+610g4vv<v<
|
||||
| v%2\/3-1$_\#!4#:*#-\#1<\1+1:/4+1g00:\_\#$1<%2/2+1\g02\-1+%-g012\/-*<v"*/
|
||||
_ >!>0$#0\#$\_-10p20p::00g4/:1+1>\#<1#*-#4:#\_$1-2*3/\2%!>0$#0\#$\_--vv|+2
|
||||
v:\p06!*-1::p05<g00+1--g01g03\+-g01-p04+1:<0p03:-1_>>$$$1-\1->>:v:+1\<v~::
|
||||
>:1+*!60g*!#v_!\!*50g0`*!40gg,::30g40g:2-#^_>>$>>:^:+1g02::\,+55_55+,@v":*
|
||||
v%2/2+*">~":< ^\-1g05-*">~"/2+*"|~"-%*"|~"\/*"|~":\-*">~"/2+%*"|~"\/*<^<:
|
||||
>60p\:"~>"*+2/2%60g+2%70p:"kI"*+2/2%60p\:"kI"*+2/2%60g+2%-\70g-"~|"**+"}"^
|
||||
|
|
@ -1,35 +1,29 @@
|
|||
use SVG;
|
||||
|
||||
role Lindenmayer {
|
||||
has %.rules;
|
||||
method succ {
|
||||
self.comb.map(
|
||||
{ %!rules{$^c} // $c }
|
||||
).join but Lindenmayer(%!rules)
|
||||
self.comb.map( { %!rules{$^c} // $c } ).join but Lindenmayer(%!rules)
|
||||
}
|
||||
}
|
||||
|
||||
my $dragon = "FX" but Lindenmayer(
|
||||
{ X => 'X+YF+', Y => '-FX-Y' }
|
||||
);
|
||||
my $dragon = "FX" but Lindenmayer( { X => 'X+YF+', Y => '-FX-Y' } );
|
||||
|
||||
$dragon++ for ^15;
|
||||
$dragon++ xx ^15;
|
||||
|
||||
say "<?xml version='1.0' encoding='utf-8' standalone='no'?>
|
||||
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN'
|
||||
'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>
|
||||
<svg width='800' height='600' version='1.1'
|
||||
xmlns='http://www.w3.org/2000/svg' transform='translate(222,325)'
|
||||
style='stroke:rgb(0,0,255);stroke-width:1'>";
|
||||
say '<rect height="100%" width="100%" style="fill:white;"
|
||||
transform="translate(-222,-325)"/>';
|
||||
my @points = 215, 350;
|
||||
|
||||
for $dragon.comb {
|
||||
state ($x, $y) = 100, 100;
|
||||
state ($x, $y) = @points[0,1];
|
||||
state $d = 2 + 0i;
|
||||
|
||||
if /F/ {
|
||||
say "<line x1='$x' y1='$y' x2='{$x += $d.re}' y2='{$y += $d.im}' />";
|
||||
}
|
||||
if /'F'/ { @points.append: ($x += $d.re).round(.1), ($y += $d.im).round(.1) }
|
||||
elsif /< + - >/ { $d *= "{$_}1i" }
|
||||
}
|
||||
|
||||
say "</svg>";
|
||||
say SVG.serialize(
|
||||
svg => [
|
||||
:600width, :450height, :style<stroke:rgb(0,0,255)>,
|
||||
:rect[:width<100%>, :height<100%>, :fill<white>],
|
||||
:polyline[ :points(@points.join: ','), :fill<white> ],
|
||||
],
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue