Project 1076

by Gulsah Iris Kocaalioglu

Description

My program’s name is Random Circles. It draws a random number of circles and each of circle has a random position, random size and random color on the canvas. None of them are cut off by the edge of the canvas. I use the constant canvas_width and canvas_height which has the canvas’s size. Besides there are min_radius and max_radius for the minimum and maximum radius that each circle can have. max_number_of_circles is using for the maximum number of circles which may be created. My program generates between 1 and max_number_of_circles circles. I used Campy Library. Campy graphics use the same canvas paradigm that we learned with Tkinter. Graphics get drawn on a canvas called GWindow or graphics window. GObjects is used for shapes like rectangle (GRect), oval (GOval), etc. This canvas acts like a real canvas where new added layers of paint overlay previous layers. It can be installed via pip (in terminal application): python3 -m pip install campy or py -m pip install campy The first step is to always create a canvas, called a GWindow in campy. I want to store the canvas in a variable so that you can access it later and continue to add other graphics objects to it: window = GWindow(width=300, height=300, title=”RandomCircles”) Once I’ve created my GWindow, I want to add GObject like oval to it. GObjects are the many different kinds of shapes that can be created using campy. GObject has properties and functions. Some of them are; obj.color : A property for accessing the object’s outline color obj.fill.color : A property for accessing the interior color obj.move(dx, dy) : Moves the object on the screen using the specified displacements I took advantage of Campy Library from internet. These are; https://web.stanford.edu/class/archive/cs/cs106ap/cs106ap.1198/handouts/h14_Campy_Reference_Guide.pdf https://campy.sredmond.io/#indices-and-tables https://pypi.org/project/campy/