-
Notifications
You must be signed in to change notification settings - Fork 0
Documentation
To start the application, you just need to create a ShapeDrawer object and call its start method:
ShapeDrawer application;
application.start();By calling the
startmethod, the application window will be created.
start method is an infinite loop, so make sure to place all your instructions before calling it.
There are multiple ways to draw a shape with this application. Here is a list of all the ways to draw shapes:
-
File
You can import and save data to a file.
To load data from a file, you need to use the
DataManagerobject of your application, which you can obtain with the following command:auto dataManager = application.get_dataManager();The
dataManageris anstd::shared_ptr.To load data from a file, use the following command:
std::string path = /* Path to your data file */ shapeManager->load(path);
This will add draw the shapes from the file.
To save data to a file, use the following command:
std::string path = /* Path to your data file */ shapeManager->save(path);
This will store all the shapes that are rendered in the application into the file.
Here is the storage structure used in data files:
-
Circle
CIRCLE x y radius r g b fill thicknessParameters:
-
CIRCLE: String "CIRCLE". -
x: x-coordinate of the circle's center. -
y: y-coordinate of the circle's center. -
radius: Circle's radius. -
r: Red component of the circle's color. -
g: Green component of the circle's color. -
b: Blue component of the circle's color. -
fill: true if circle filled. -
thickness: Circle's thickness.
-
-
Rectangle
RECTANGLE x1 y1 x2 y2 r g b fill thicknessParameters:
-
RECTANGLE: String "RECTANGLE". -
x1: x-coordinate of the rectangle's top left vertex. -
y1: y-coordinate of the rectangle's top left vertex. -
x2: x-coordinate of the rectangle's bottom right vertex. -
y2: y-coordinate of the rectangle's bottom right vertex. -
r: Red component of the rectangle's color. -
g: Green component of the rectangle's color. -
b: Blue component of the rectangle's color. -
fill: true if rectangle filled. -
thickness: Rectangle's thickness.
-
-
Triangle
TRIANGLE x1 y1 x2 y2 x3 y3 r g b fill thicknessParameters:
-
TRIANGLE: String "TRIANGLE". -
x1: x-coordinate of the triangle's first vertex. -
y1: y-coordinate of the triangle's first vertex. -
x2: x-coordinate of the triangle's second vertex. -
y2: y-coordinate of the triangle's second vertex. -
x3: x-coordinate of the triangle's third vertex. -
y3: y-coordinate of the triangle's third vertex. -
r: Red component of the triangle's color. -
g: Green component of the triangle's color. -
b: Blue component of the triangle's color. -
fill: true if triangle filled. -
thickness: Triangle's thickness.
-
-
Line
LINE x1 y1 x2 y2 r g b thicknessParameters:
-
LINE: String "LINE". -
x1: x-coordinate of the line's first vertex. -
y1: y-coordinate of the line's first vertex. -
x2: x-coordinate of the line's second vertex. -
y2: y-coordinate of the line's second vertex. -
r: Red component of the line's color. -
g: Green component of the line's color. -
b: Blue component of the line's color. -
thickness: Line's thickness.
-
⚠️ Remember to place these lines before the render loop in therunmethod. -
-
Input
When the application is running, you can also draw and delete shapes using your mouse.
Here is a detailed list of mouse actions:
-
LEFT-CLICK: Draw a shape based on the drawing settings. -
RIGHT-CLICK: Delete the shape at the clicked position. -
SCROLL-UP: Increase the drawing shape's thickness. -
SCROLL-DOWN: Decrease the drawing shape's thickness.
-
-
Option Menu
When drawing in the application if you press on
ESCAPEyou will have access to buttons that will allow you to choose what shapes, color and thickness you want to use when drawing.Additionally, there are two drawing modes:
- Random drawing: It creates a shape with a random size around your click.
- Classic drawing: You place one vertex at a time to construct the shape.