function cls(c)
{
ctx.fillStyle = c;
ctx.fillRect(0, 0, canvas.width, canvas.height);
}
function pset(x, y, c)
{
ctx.fillStyle = c;
ctx.fillRect(x, y, 1, 1);
}
function color(c)
{
ctx.fillStyle = c;
ctx.strokeStyle = c;
}
function leaf(d)
{
var x, y, x1, y1, i, r;
cls('#000');
x = 0; y = 0;
for (i = 0; i < 10000; i++)
{
pset(320 + x * 30 * d, 320 - y * 30, '#0f0');
r = Math.random();
if (r < 0.01)
{
x1 = 0;
y1 = y * 0.16
}
else if (r < 0.01+0.07)
{
x1 = x * 0.20 - y * 0.26
y1 = x * 0.23 + y * 0.22 + 1.60
}
else if (r < 0.01+0.07+0.07)
{
x1 = y * 0.28 - x * 0.15
y1 = x * 0.26 + y * 0.24 + 0.44
}
else
{
x1 = x * 0.85 + y * 0.04
y1 = y * 0.85 - x * 0.04 + 1.60
}
x = x1; y = y1;
}
}
var rad = Math.PI * 2;
document.body.addEventListener('keydown', event =>
{
if (event.keyCode == 13)
{
rad = Math.PI * 2;
window.requestAnimationFrame(idle)
}
});