if (fx.state == 0)
if (fx.state == 0 ||
fx.start.constructor != Array ||
fx.end.constructor != Array)
Sometimes when this code is executed. fx.State is not 0, but fx.start and fx.end haven’t been initialized as RGB arrays. In the updated code, we initialize the fx.start and fx.end arrays if they haven’t been initialized.