Task 3 was to make a popup window that has options for random distribution in the x and y axes. Using an outline the task linked to, I made two listboxes in the body method, and packed them into the window vertically. Then, I inserted "uniform" and "gaussian" as selectable options in both. In the apply method, which hitting "ok" triggers, I changed the fields for the current x and y distribution options to match the currently active selection in their respective listboxes. I passed in the displayApp class for this reason. Then, when creating the points, I check the strings associated with the x and y distribution fields, and use a different random function depending on their values. This is shown here: Image Added
For my first extension, making the current distribution settings saved as the defaults when opening the window to change them, I simply used the activate method in the body method of the DistSelection class. I passed in the currently selected index by checking the fields of the displayApp class. I also used the select_set method of the listboxes in the same way to make the currently active distribution highlighted for clarity.
The second extension I did was adding a slider for changing the amount of points to draw. This was a simple matter of adding two lines to buildControls, shown below, and then telling the point-creation method to make points in the range of self.slider.get(). Image Added
For the last extension, I added the ability to make square and diamond shapes. I modeled this after the popup window for choosing distribution type, only with one listbox. I had a field for the shape in displayApp, and I checked this when drawing the points. The challenges came with making a diamond. This, unlike a square, cannot be treated similarly to a circle, with two x and two y values. It needs to have 4 of each, and is a polygon. This also means it needs to be moved differently in the mouse movement-handling method. After a while, I found that I could give shapes I draw tags, and by checking if the shapes had tags, I could differentiate between diamonds and non-diamonds. For diamonds, I moved 8 points, while for others, it was only 4. This is shown below: Image Added
And this is where I decided what to draw when placing points: Image Added
Below are two pictures of my program's functionality. The blue is Gaussian in its x axis, is more sparse than the red, and is is square. Meanwhile, there is a lot of red, which takes diamond form, and has gaussian distribution in both axes. The effect of Gaussian distribution can be seen in the center-clumping we can see in the red. The distribution makes it more likely for points to be near the center, and less likely to be farther away, based on the standard deviation provided. The blue, which has Gaussian distribution on its x axis, shows this trend horizontally, but vertically, one can see that it does not go down into the middle of the y axis very much.