MENU

Fun & Interesting

Coding Challenge #13: Reaction Diffusion Algorithm in p5.js

The Coding Train 209,363 9 years ago
Video Not Working? Fix It Now

In this coding challenge, I visualize a Reaction Diffusion simulation using the Gray Scott model in JavaScript (with the p5.js library). Code: https://thecodingtrain.com/challenges/13-reaction-diffusion ๐Ÿ•น๏ธ p5.js Web Editor Sketch: https://editor.p5js.org/codingtrain/sketches/govdEW5aE ๐ŸŽฅ Previous video: https://youtu.be/f0lkz2gSsIk?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH ๐ŸŽฅ Next video: https://youtu.be/0jjeOYMjmDU?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH ๐ŸŽฅ All videos: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH References: ๐Ÿ“– Karl Sims' Reaction Diffusion Tutorial: http://karlsims.com/rd.html ๐Ÿ““ 2D Array Tutorial: https://processing.org/tutorials/2darray/ ๐Ÿ“• My NOC class on Kadenze: https://www.kadenze.com/courses/the-nature-of-code/info Videos: ๐Ÿ”ด Livestream Archive: https://youtu.be/FYRINCEDVKI?t=6697s Related Coding Challenges: ๐Ÿš‚ #85 The Game of Life: https://youtu.be/FWSR_7kZuYg ๐Ÿš‚ #90 Floyd-Steinberg Dithering: https://youtu.be/0L2n8Tg2FwI ๐Ÿš‚ #103 Fire Effect: https://youtu.be/X0kjv0MozuY Timestamps: 0:00 Introducing today's topic 0:36 The Gray-Scott model 1:41 Key pieces of the algorithm 4:24 Convolutions 7:01 2D arrays 9:00 The grid stores the amount of a and b chemicals across every pixel 10:30 Create another array to store the next generation 11:37 Dealing with the pixel array 12:55 Set the pixel colors based on the amount of a and b 16:14 Write a function to swap the current and next grid 19:30 Add the reaction diffusion formulas to the code 24:27 Time steps 27:29 Add the Laplace functions 33:45 Seed a whole area with b 36:37 Recap of the code and suggestions for creative possibilities Editing by Mathieu Blanchette Animations by Jason Heglund Music from Epidemic Sound ๐Ÿš‚ Website: http://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://discord.gg/hPuGy2g ๐Ÿ’– Membership: http://youtube.com/thecodingtrain/join ๐Ÿ›’ Store: https://standard.tv/codingtrain ๐Ÿ–‹๏ธ Twitter: https://twitter.com/thecodingtrain ๐Ÿ“ธ Instagram: https://www.instagram.com/the.coding.train/ ๐ŸŽฅ Coding Challenges: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH ๐ŸŽฅ Intro to Programming: 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 #math #reactiondiffusion #javascript #p5js

Comment