codepens/fredrikaflowfield-heart
Dym Sohin f132183c1d init 2023-10-06 23:12:53 +02:00
..
dist init 2023-10-06 23:12:53 +02:00
src init 2023-10-06 23:12:53 +02:00
README.markdown init 2023-10-06 23:12:53 +02:00
license.txt init 2023-10-06 23:12:53 +02:00

README.markdown

Fredrika ❤️❤️❤️❤️❤️ - Flowfield Heart

_A Pen created at CodePen.io. Original URL: https://codepen.io/DonKarlssonSan/pen/XGgBae.

Inspired by Daniel Shiffman's Coding Train episode Coding Challenge #134 Heart Curve: https://www.youtube.com/watch?v=oUBAi9xQ2X4

Setup:

  • Draw a heart using the sixth curve found on Wolfram
  • Fill the curve
  • Store the image for future reference
  • Clear the screen
  • Fill the screen with particles

Draw loop:

  • Clear the screen with semi transparent black to create particle trails as the particles move around
  • If a particle is inside the heart (checked by referencing the image we stored during setup): affect its motion with a flow field(1), else: let the particle turn in a random direction and move a step.

(1) I have an extensive blog post about how a flow field works.