I don't know how bitaddress and random library works exactly, but the short version is :
1. User move their mouse
2. You record mouse pointer position every time position change or/and every few milisecond
3. Stop when you get enough list of mouse pointer position
4. Feed the list into function, such as Linear congruential generator or Linear-feedback shift register (both of them are unsecure, but shouldn't be too hard to understand)
You could write your own function, but most likely it will be very insecure.
The linux kernel uses mouse movements, inter-keyboard timings, CPU interrupts and other non-deterministic events to gather entropy.
That's definitely random enough to generate a private key.
/dev/urandom also exist & commonly used rather than /dev/random, check https://unix.stackexchange.com/q/324209 for more info