Think of a description yourself, EC got turned into a goddamn wasteland, so I will not waste my time on writing an explanation.
I designed this circuit for myself, but it might be helpful for some of you.
I am actually just sitting here waiting for my math exam to begin, so here is a small explanation: This circuit generates a PWM signal corresponding to mains voltage. Change the frequency of the AC source on the right and you will see.
HaVe FuN wItH eLeCtRoNiCs