#include#include int main() { // create a window Window myWindow; myWindow.setSize(600, 400); // create a DrawingContext object for the window DrawingContext dc(myWindow); // set the background color of the window to light gray dc.setColor(Color::LightGray); dc.fillRect(0, 0, myWindow.getWidth(), myWindow.getHeight()); return 0; }
#includeIn this example, we create a window and a DrawingContext object for the window. We then use the setColor method of the DrawingContext object to set the color to a custom color (in this case, red). Finally, we draw a circle with the specified color at (300, 200) with a radius of 100. Package library: Graphics library#include int main() { // create a window Window myWindow; myWindow.setSize(600, 400); // create a DrawingContext object for the window DrawingContext dc(myWindow); // set the color to red dc.setColor(Color(255, 0, 0)); // draw a circle at (300, 200) with radius 100 dc.drawCircle(300, 200, 100); return 0; }