Coding Challenge 185: Unfolding Fractals
From The Coding Train ยท ยท 31 min

The player loads from YouTube only when you click. It uses YouTube's privacy-enhanced mode.
If the video does not play, the owner may have turned off embedding. Watch it on YouTube instead.
Description
25% off The Nature of Code book with code CHOOCHOO at https://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: https://thecodingtrain.com/challenges/185-dragon-curve
๐ Watch this video ad-free on Nebula https://nebula.tv/videos/codingtrain-coding-challenge-184-dragon-curve
p5.js Web Editor Sketches: ๐น๏ธ Dragon curve animation: https://editor.p5js.org/codingtrain/sketches/LXDsoCSZs ๐น๏ธ Dragon curve color variation: https://editor.p5js.org/codingtrain/sketches/7nNd-f7iY ๐น๏ธ Dragon curve noise variation: https://editor.p5js.org/codingtrain/sketches/7r7ZIE4dc
๐ฅ Previous: https://youtu.be/dJNFPv9Mj-Y?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH ๐ฅ All: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
References: ๐ The Nature of Code: https://natureofcode.com/ ๐ Nature of Code shop: https://store.natureofcode.com/products/the-nature-of-code ๐ Dragon Curve: https://en.wikipedia.org/wiki/Dragon_curve ๐ concat() function: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat
Videos: ๐ฅ https://youtu.be/UBuPWdSbyf8 ๐ฅ https://www.youtube.com/watch?v=wCyC-K_PnRY
Related Coding Challenges: ๐ https://youtu.be/0jjeOYMjmDU ๐ https://youtu.be/E1B4UoSQMFw ๐ https://youtu.be/jPsZwrV9ld0 ๐ https://youtu.be/i-k04yzfMpw ๐ https://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: https://thecodingtrain.com/ ๐พ Share Your Creation! https://thecodingtrain.com/guides/passenger-showcase-guide ๐ฉ Suggest Topics: https://github.com/CodingTrain/Suggestion-Box ๐ก GitHub: https://github.com/CodingTrain ๐ฌ Discord: https://thecodingtrain.com/discord ๐ Membership: http://youtube.com/thecodingtrain/join ๐ Store: https://standard.tv/codingtrain ๐๏ธ Twitter: https://twitter.com/thecodingtrain ๐ธ Instagram: https://www.instagram.com/the.coding.train/
๐ฅ https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH ๐ฅ https://www.youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA
๐ p5.js: https://p5js.org ๐ p5.js Web Editor: https://editor.p5js.org/ ๐ Processing: https://processing.org
๐ Code of Conduct: https://github.com/CodingTrain/Code-of-Conduct
This description was auto-generated. If you see a problem, please open an issue: https://github.com/CodingTrain/thecodingtrain.com/issues/new
#fractals #dragoncurve #natureofcode #p5js #javascript