



Ahhhh failed to create the electrons flow in light bulb. Planed to
- add some particles around strings
- restrain patterns to fit within the lightbulb, using different canvas
Things worth mentioned:
- I used keyPressed() to change the gravity. Kill the original gravity and use “A, W, D, S” keys to control the direction of force.
ParticleBehavior2D b = physics.behaviors.get(physics.behaviors.size()-1);
physics.removeBehavior(b);
if (key == 'a') {
physics.addBehavior(new GravityBehavior(new Vec2D(random(-0.3), random(-0.05, 0.05))));
}
else if (key == 'w') {
physics.addBehavior(new GravityBehavior(new Vec2D(random(-0.05, 0.05), random(-0.3))));
}
else if (key == 'd') {
physics.addBehavior(new GravityBehavior(new Vec2D(random(0.3), random(-0.05, 0.05))));
}
else if (key == 's') {
physics.addBehavior(new GravityBehavior(new Vec2D(random(-0.05, 0.05), random(0.3))));
}
- Use the color function of Toxiclibs, measure the direction of the spring and then map it into 0~1, and then some crazy codes to set up the color of stroke.
for (VerletSpring2D s: strings) {
float currHue = map(s.b.sub(s.a).heading(), -PI, PI, 0, 1);
stroke(TColor.newHSV(currHue, 1, 1).toARGB());
line(s.a.x, s.a.y, s.b.x, s.b.y);
}
Original version, without vertex to fill the mesh. Looks like seaweeds.
Looks like worms.
And here are some tutorials and examples I found useful!
- Nature of Code by Daniel Shiffman
- SpringPlay by Justin Pinkney
- @ creativeapplications

