The bolt's path is built by repeatedly offsetting its midpoints to branch outward, while screen brightness is computed on a curve that spikes up fast and eases back down slowly to create the flash.