Write a C++ program using the raylib library, which creates a resizable window and…
- User
Write a C++ program using the raylib library, which creates a resizable window and displays a background.png image in it. The image displayed on the screen should NOT be scaled to the size of the window, and loaded and displayed in real size. The aspect ratio of the original image should be the same as the aspect ratio of the image in pixels, this is very important. The camera should initially be centered on the image. The camera should have a zoom and zoom function when scrolling the mouse wheel back and forth. The minimum approximation relative to the starting one is 0.20f, and the maximum is 40.0f. The camera can be moved by dragging with the right mouse button held down. The minimum camera position for X is 0-the length of the background image/3, for Y is 0-the height of the background image/3. The maximum camera position by X is the length of the image + the length of the image /3, and by Y is the height of the image + the height of the image/3. The camera should move clearly with the cursor with a slight interpolation of the position (you need to write a function for it). Also, the program should have a function for drawing polygon points at world coordinates. Red circles with a radius of 0.5f should be displayed in place of the polygon points. A polygon with a random color fill should be drawn between the points (to get a random color, you need to write a function). The polygon should have a black outline with a thickness of 2 screen pixels. The outline display (visible or not visible) can be switched by pressing the 'S' key. If the polygon is drawn, then pressing the Enter key will create a file provinces.txt in the folder where the application is located. The file will contain 2 lines for each polygon: id (ordinal number), which is assigned to the drawn polygon even when the first point is drawn, and the coordinates of the polygon points in X and Y, which are listed as follows: X,Y; X,Y; X,Y; and so on. If the file is not empty and there are filled lines in it, then the new polygon will be saved on the next two empty lines. The coordinates of the points and the id of the polygons will be read when the application is opened and the polygons will be displayed in the window. There should also be a function to remove the last drawn point from the polygon being drawn (the polygons being drawn should have the isDrawingNow bool parameter while the application is running). There should also be a function to switch between drawing and polygon removal modes. The mode is switched with the 'D' key. Initially, the drawing mode is enabled, if the drawing mode is enabled, then by clicking the left mouse button, polygon points will be drawn, if the mode is switched to deleting polygons, then when you click on the polygon, it will be deleted from both memory and display, and from the file provinces.txt if it was recorded there. Before deleting, it is important to get the polygon id so that the desired polygon is deleted. The polygon should not have a maximum number of points. Write the full code with the implementation of all functions
- Assistant