June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,18 @@
using Luxor
function dragon(turtle::Turtle, level=4, size=200, direction=45)
if level != 0
Turn(turtle, -direction)
dragon(turtle, level-1, size/sqrt(2), 45)
Turn(turtle, direction*2)
dragon(turtle, level-1, size/sqrt(2), -45)
Turn(turtle, -direction)
else
Forward(turtle, size)
end
end
Drawing(900, 500, "./Dragon.png")
t = Turtle(300, 300, true, 0, (0., 0.0, 0.0));
dragon(t, 10,400)
finish()
preview()

View file

@ -11,20 +11,23 @@ my $dragon = "FX" but Lindenmayer(
{ X => 'X+YF+', Y => '-FX-Y' }
);
$dragon++ for ^10;
$dragon++ for ^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='100%' height='100%' version='1.1'
xmlns='http://www.w3.org/2000/svg'>";
<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)"/>';
for $dragon.comb {
state ($x, $y) = 100, 100;
state $d = 2 + 0i;
if /F/ {
say "<line x1='$x' y1='$y' x2='{$x += $d.re}' y2='{$y += $d.im}' style='stroke:rgb(0,0,0);stroke-width:1'/>";
say "<line x1='$x' y1='$y' x2='{$x += $d.re}' y2='{$y += $d.im}' />";
}
elsif /< + - >/ { $d *= "{$_}1i" }
}

View file

@ -27,5 +27,5 @@ p=translate(left(p,1), 0123, 'NESW'); $= /*get the orientation for drago
do r=minX to maxX; a= /*nullify the line that will be drawn. */
do c=minY to maxY; a=a || @.r.c /*create a line (row) of curve points. */
end /*c*/ /* [↑] append a single column of a row.*/
if a\='' then say strip(a, 'T') /*display a line (row) of curve points.*/
if a\='' then say strip(a, "T") /*display a line (row) of curve points.*/
end /*r*/ /*stick a fork in it, we're all done. */