Flow-field.js – A library for generating flow fields

Author: romellogoodman

Score: 81

Comments: 14

Date: 2021-11-29 11:18:34

Web Link

________________________________________________________________________________

mkl wrote at 2021-11-29 12:20:01:

Looks neat! I'm wondering why/how the first two results pictures (under "Values For num_steps") in

https://tylerxhobbs.com/essays/2020/flow-fields

have flow lines that are crossing each other. The paths follow a direction field, so that shouldn't happen except where the gradient vector vanishes, which doesn't seem to be the case there.

nrjames wrote at 2021-11-29 12:29:10:

There are many different ways to move objects through a flow field. Some people use the vectors to accelerate particles, others as instructions for instantaneous rotation, etc. The crossing lines aren't necessarily following the flow field in those images, but likely are just using vectors as an input to another set of instructions.

mkl wrote at 2021-11-29 13:07:37:

Yes, okay, but the algorithm described just before that treats the vectors as tangents to the path. The pseudocode does a complicated-seeming grid lookup instead of just evaluating the function, but apart from that it's just following the vectors as tangents.

joeberon wrote at 2021-11-29 14:10:28:

Tyler Hobbs usually keeps a large distance between the exposition of the algorithm and the actual artistic example for the sake of maintaining artistic technique secrecy.

imdsm wrote at 2021-11-29 20:53:23:

A demo would be great for those with more curiosity than time

romellogoodman wrote at 2021-11-29 22:44:22:

Added to the readme but here is a demo

https://codesandbox.io/s/flow-field-demo-kkzmg

code_biologist wrote at 2021-11-30 01:13:07:

The GUI library that demo uses is pretty slick:

https://github.com/pmndrs/leva

mkl wrote at 2021-11-29 21:42:18:

Click the very first link.

darkhorse13 wrote at 2021-11-29 18:12:55:

This is freaking awesome! 2 questions:

- Can I set the result as the background of a <div> element? Or does it have to be on a canvas? Either way, an actual usage example in the README would do wonders.

- Does anyone know of anything similar like this but in Python?

romellogoodman wrote at 2021-11-29 22:45:29:

I added an example to the readme but generally speaking this framework is pretty agnostic and you can use the x, y coordinates in each line with any library

darkhorse13 wrote at 2021-11-29 23:10:05:

Thank you, this is excellent.

roland35 wrote at 2021-11-29 12:43:52:

I have recently gotten into pen plotters (like the axi-draw) and needed some tools for generative code for art! This looks like an interesting base for a variety of styles

marstall wrote at 2021-11-29 14:35:55:

very cool! would love to try to play around with this within a web page's design. kind of like how one might use gradients but on a whole new level ...

dave_sullivan wrote at 2021-11-29 12:38:06:

Nice, I've been looking for something like this, will play around with it.