Initial Code, from last week’s random walk neon lines
In the initial code, basic variables x
and y
are used to represent position, requiring separate management for each coordinate.
https://editor.p5js.org/yc4351/sketches/7k_ZAt8rz
glowEffect()
function uses a loop to draw the same line multiple times with different strokeWeight
values and varying transparency (by replacing the alpha value in the color). This simulates a glowing effect. This part was from chatgpt.Week 2 Iteration: Using Vectors
In the initial code, basic variables x
and y
are used to represent position, requiring separate management for each coordinate.
Using createVector()
, ppl can play with position, velocity, acceleration, etc., into a single entity.
Vector did improve code readability, also make it easier to try other physics.
https://editor.p5js.org/yc4351/sketches/g5Vi88OPi
Speed:
In the initial code, speed control was achieved by directly changing the position using a fixed step size (stepSize
). Each update simply added a randomly selected step to the coordinates.
After vector:
velocity.limit()
: maximum lengthvelocity.mult()
: friction(reducing the velocityGlow effect: same logic, but using vector
Iteration 2:
I was trying to making flashes but haven’t finished yet!
WIP⬇️