I would like the color of the Arrows to change depending on the value of F you get for them.
This could happen inside this function.
function drawElectricField() {
for (let x = 0; x < 1200; x += 40) {
for (let y = 0; y < 1200; y += 40) {
let base = new Complex(x, y);
let F = calculateElectricFieldVector(base).mul(1e15);
//getColor(F) get corresponding color out of F value
let absF = F.abs();
F = F.mul(1/absF);
drawArrow(base, new Complex(base.re + F.re, base.im + F.im),[35, 144, 145]);
}
}
}
The color variable is already a parameter of my drawArrow funciton.