Simple 2D Xray diffraction

Consider the blue area to be the cell boundaries of a two-dimensional crystal. Five atoms can be added just to the area by clicking the mouse. Once all five atoms have been added, click on the X-ray button and a "diffraction pattern" will appear below it.

This applet is not totally bug-free. If you add less than five atoms, the unadded atoms are still stored in the program and used for the diffraction pattern, rather than being discarded. Oops!

X ranges from 0 to 450. Y ranges from 0 to 300.

Applet goes here.
The source code