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
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










