{
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();
}