Public
Edited
Mar 28
Fork of An L-system
Insert cell
Insert cell
Insert cell
{
const width = 640;
const height = 240;
const paths = [];
const context = cm.mat().translate(width / 2, height);

branch(80, 0);

function branch(len, rotation) {
if (len < 2) return;

context.push();
context.rotate(rotation);
paths.push({ d: `M0,0L0,${-len}`, transform: context.transform() });

context.translate(0, -len);
len *= 0.67;
branch(len, angle);
branch(len, -angle);
context.pop();
}

const app = cm.app({
width: width,
height: height,
draw: [
cm.svg("path", paths, {
d: (d) => d.d,
transform: (d) => d.transform,
stroke: "black",
strokeWidth: 1.5
})
]
});

return app.render();
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more