Built with blockbuilder.org
forked from danbgray's block: L-System
forked from danbgray's block: Sierpinski
xxxxxxxxxx
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="lsystem.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
input[type='text'] { width:340px; }
form ul li { list-style-type:none; }
</style>
</head>
<body>
<script>
/* The Seed / for Sierpinski */
var svg = d3.select("body").append("svg")
.attr("width", 960)
.attr("height", 768)
/* Variables */
position = [550,462];
stroke_length = 7;
levels = 6;
/* Define the seed and rules */
w = G(["F","G"],
"F-G-G",
{"F":"F-G+F+G-F","G":"GG"},
levels);
/* Draw with left turn angle of 60˚ and right turn angle of 60˚, starting out
angle of -90˚
*/
path = drawToPath(position, w, stroke_length, -Math.PI, 2*Math.PI/3);
/* Add to path */
tree = svg.append("svg:path")
.attr("d",path)
.style("stroke-width","1")
.style("stroke","purple")
.style("fill","orange");
</script>
</body>
https://d3js.org/d3.v4.min.js