Coding Challenge 185: Unfolding Fractals @TheCodingTrain
Coding Challenge 185: Unfolding Fractals  @TheCodingTrain
Uploaded August 2024 | Updated September 2026, 1 week ago
25% off The Nature of Code book with code CHOOCHOO at natureofcode.com (comes with exclusive sticker+bookmark).

The Dragon Curve fractal is created by repeatedly folding a strip of paper in half, then unfolding it to form a curve. In this challenge, I attempt to code an animation of the Dragon Curve forming with p5.js in JavaScript. Code: thecodingtrain.com/challenges/185-dragon-curve

πŸš€ Watch this video ad-free on Nebula nebula.tv/videos/codingtrain-coding-challenge-184-dragon-curve

p5.js Web Editor Sketches:
πŸ•ΉοΈ Dragon curve animation: editor.p5js.org/codingtrain/sketches/LXDsoCSZs
πŸ•ΉοΈ Dragon curve color variation: editor.p5js.org/codingtrain/sketches/7nNd-f7iY
πŸ•ΉοΈ Dragon curve noise variation: editor.p5js.org/codingtrain/sketches/7r7ZIE4dc

πŸŽ₯ Previous: youtu.be/dJNFPv9Mj-Y?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
πŸŽ₯ All: youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH

References:
πŸ“• The Nature of Code: natureofcode.com
πŸ›’ Nature of Code shop: store.natureofcode.com/products/the-nature-of-code
πŸ”— Dragon Curve: en.wikipedia.org/wiki/Dragon_curve
πŸ”— concat() function: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat

Videos:
πŸŽ₯ youtu.be/UBuPWdSbyf8
πŸŽ₯ youtube.com/watch?v=wCyC-K_PnRY

Related Coding Challenges:
πŸš‚ youtu.be/0jjeOYMjmDU
πŸš‚ youtu.be/E1B4UoSQMFw
πŸš‚ youtu.be/jPsZwrV9ld0
πŸš‚ youtu.be/i-k04yzfMpw
πŸš‚ youtu.be/dSK-MW-zuAc

Timestamps:
00:00 Introduction
00:36 The Nature of Code book
01:43 Explain algorithm
03:38 Start coding
05:05 Write rotate function
07:05 Rotate all the segments
11:30 We have the dragon curve!
12:00 Add animation
16:31 Add the starting positions for a and b
21:43 Scale the lines
24:08 Add a nextGeneration() function
25:16 The reduction ratio
26:44 Target zoom
28:57 Challenge complete!
29:57 What can you do?
30:25 Outro

Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound

πŸš‚ Website: thecodingtrain.com
πŸ‘Ύ Share Your Creation! thecodingtrain.com/guides/passenger-showcase-guide
🚩 Suggest Topics: github.com/CodingTrain/Suggestion-Box
πŸ’‘ GitHub: github.com/CodingTrain
πŸ’¬ Discord: thecodingtrain.com/discord
πŸ’– Membership: youtube.com/thecodingtrain/join
πŸ›’ Store: standard.tv/codingtrain
πŸ–‹οΈ Twitter: twitter.com/thecodingtrain
πŸ“Έ Instagram: instagram.com/the.coding.train

πŸŽ₯ youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
πŸŽ₯ youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA

πŸ”— p5.js: p5js.org
πŸ”— p5.js Web Editor: editor.p5js.org
πŸ”— Processing: processing.org

πŸ“„ Code of Conduct: github.com/CodingTrain/Code-of-Conduct

This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/thecodingtrain.com/issues/new

#fractals #dragoncurve #natureofcode #p5js #javascript
Coding Challenge 185: Unfolding Fractals16.17: Inheritance in JavaScript - Topics of JavaScript/ES6Coding Challenge #159: Simple Pendulum SimulationAdvent of Code (Side Project Saturday!)Coding Challenge 168: MandelBulb 3D FractalIntegration Test Stream #13.4 Polar Coordinates - The Nature of CodeI, Robot5.4 Arrive Steering Behavior - The Nature of CodeCoding Challenge: 3D on Apple II2.4: random() Function - p5.js Tutorial5.1 Autonomous Steering Agents Introduction - The Nature of Code
The Coding Train |

Coding Challenge 185: Unfolding Fractals

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER