L-system tree · gpt-3.5-turbo
Using the pre-provided p5.min.js (global p5), grow a procedural L-system fractal tree that branches recursively and sways gently in the wind.
This one-shot run produced no runnable artifact.
agent produced no index.html
The transcript below shows what the model did — read it to see why the one shot fell short.
transcript · 2 messages
Using the pre-provided p5.min.js (global p5), grow a procedural L-system fractal tree that branches recursively and sways gently in the wind.
To create a procedural L-system fractal tree that branches recursively and sways gently in the wind using p5.js, we need to define the L-system rules for the tree, implement the recursive branching logic, and add wind effect for swaying. Here's the complete code for the index.html file: ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Procedural Fractal Tree with Wind Effect</title> <style> body { margin: 0; display: flex; justify-content: center; align-items: center; height: 100vh; background-color: #f0f0f0; } </style> </head> <body> <script src="p5.min.js"></script> <script> function setup() { createCanvas(800, 600); background(240); // Define L-system rules let axiom = 'F'; let rules = { 'F': 'FF+[+F-F-F]-[-F+F+F]' }; let sentence = axiom; let len = 100; let angle; // Turtle graphics implementation let render = () => { background(240); translate(width / 2, height); stroke(0, 150, 0); for (let char of sentence) { if (char == 'F') { line(0, 0, 0, -len); translate(0, -len); } else if (char == '+') { rotate(angle); } else if (char == '-') { rotate(-angle); } else if (char == '[') { push(); } else if (char == ']') { pop(); } } }; // Create next generation of tree let generate = () => { len *= 0.7; let nextSentence = ''; for (let char of sentence) { if (rules[char]) { nextSentence += rules[char]; } else { nextSentence += char; } } sentence = nextSentence; render(); }; // Apply wind effect let sway = () => { angle = map(sin(frameCount * 0.05), -1, 1, -PI / 40, PI / 40); render(); }; angle = PI / 6; render(); // Grow the tree with recursion let count = 0; let interval = setInterval(() => { generate(); count++; if (count == 5) { clearInterval(interval); setInterval(sway, 50); } }, 1000); } </script> </body> </html> ``` This code sets up a canvas, defines L-system rules for the fractal tree, implements recursive branching logic to grow the tree, and adds a wind effect to make the tree sway gently. Please let me know if you would like any modifications or further assistance.
TAKE IT TO CODE
This run produced no artifact — reuse the prompt with a different model or your own pi-agent run.