-
Notifications
You must be signed in to change notification settings - Fork 7
Page 2: Architecture
The application interfaces with the user in a very simple way, as the following diagram shows:
Basically, the user specifies, either through the GUI or by command line, the name of the image, its output location, and as optional parameter, a seed (that will control the Random Number Generation). If everything its correct, then a new image is generated. Otherwise, the application provides feedback of what went wrong.
A more detailed view of such process is shown in the next figure:
The architecture of 8-Bit Hubble tries to be modular, high-cohesive, low-coupled, with clean interfaces and easy to understand. These goals gives as a result the following modules:
Each module has its own source folder under <root_dir>/project/dev/src directory, making it easy to access to its code. The name of the modules has been chosen to be as descriptive as possible -in fact, naming of certain functions and variables have been made following the real world objects, like "canvas" and "brush". In general, readability has been the main goal to achieve in the whole project.
A quick description of each module is provided:
-
cli: CLI module (Command Line Interface) implements the ENTRY POINT of the application in its CLI version. It parses the input arguments provided by the user, and performs the required operations (i.e: print version, help message, generate image, or print error message).
-
gui: It implements the GTK source of the GUI and the ENTRY POINT for such version.
-
big_bang_core: This module represents the "core" algorithm of the application. It checks the user configuration, generates the random galaxy and writes it in the png file, alongside with related cleanup and error handling operations. It is called "big_bang" because, as the homonymous theory, its the "origin" of the data.
-
status_reporter: Status reporter module is the "Error handler" module of the application. It defines all possible error codes, used to check if operations are being executed as expected. It provides a feedback or "debug" functionality too, to warn about encountered problems.
-
image_writer: Image writer generates ("writes") the final PNG image with the created galaxy. Its core is the PNG library to create the PNG image with the required data (magic number, header data, etc).
-
user_config_checker: As it name implies, the module checks that the configuration provided by the user to generate the galaxy is correct in terms of: valid image name, valid output directory, valid seed (if provided), etc.
-
galaxy_generator: Galaxy_generator module implements the CORE algorithm of the application. It initializes the canvas and the palette, and then, by layers, print the sprites on it, in a random fashion (location, size, color).
-
canvas: Contains both the data structure representing the canvas (where the galaxy will be painted), and related management operations. The core concept of a canvas is its dimensions, width and height that define at the same time the size of the output image.
-
palette: Palette implements the data structure that represents the real "palette" of colors. It also implements the required methods to obtain a color from it, and generate tints and shadows, like a real painter would do.
-
rng: RNG module provides a clean interface to deal with Random Number Generator methods. It basically generates random numbers on demand. Generation can be configured through a seed.
-
sprites: As it names implies, Sprites module contains the sprites that can be generated in the galaxy. A sprite is characterized by its size, and the pixels where it shall be painted. The module provides a clean interface to "stamp" or "print" a sprite into the canvas.
-
brush: Contains the data structure that represents a painting brush, characterized by the color loaded on it, its position on the canvas, and the "density" of the brushstrokes (more or less objects being painted in the canvas).
-
app_info: Provides textual data of the application, like HELP and VERSION messages, as well as the functions to print them.