Re:Show HN: Neon – Generative art piece made using 2D vector...
by achow on Wednesday January 22, 2020 @07:59AM
(#22117124)
> I know it can be cumbersome to navigate a long history..
Maybe what you can do is use Neon logo (top left) as reset. Clicking on that takes one back to the original state. After playing around a bit, I wanted to start again and clicked on that logo (multiple times) expecting that to wipe the slate clean and I can restart my exploration again.
As for how it works, I plan to do a full write up on my blog. But I'll give you a short summary.
- I generate a random vector field (https://en.wikipedia.org/wiki/Vector_field). It is not completely random, I pull them all slightly to the right, as chaos is rarely visually pleasing.
- Then I generate random starting point for each line.
- For each point, I find all vectors in certain radius, and apply their force to the dot. The further away the vector is, the weaker force applies to the point. This will give me next point.
- I repeat the process for the new point, until line is out of bounds or line reaches length of 100 point.
- Now line looks like a array of points (x, y coordinate pairs). Using these points, I draw smooth bezier curve.
That sums it up I think. The whole thing has some random aspects, params controlled by the user and some I tweaked how I like them to give what I think is visually pleasing. Try enabling debug mode and playing with controls.
This codepen is my initial exploration, the code is very similar to the final think and it might be easier to understand.
https://codepen.io/stanko/pen/rNavBvN
EDIT: Formatting.