wxDC* dc = wxClientDC(this); dc->SetPen(wxPen(wxColor(255, 0, 0), 3)); // red pen with thickness of 3 dc->DrawLine(0, 0, 100, 100); // draws a line from (0, 0) to (100, 100)
wxDC* dc = wxClientDC(this); dc->SetBrush(wxBrush(wxColor(0, 255, 0))); // green brush dc->SetPen(wxPen(wxColor(0, 0, 255), 2)); // blue pen with thickness of 2 dc->DrawRectangle(50, 50, 100, 50); // draws a rectangle with top-left corner at (50, 50), width of 100 and height of 50
wxDC* dc = wxClientDC(this); dc->SetFont(wxFont(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD)); dc->SetTextForeground(wxColor(0, 0, 255)); // blue text color dc->DrawText("Hello, world!", 50, 50); // draws the text at (50, 50)This code creates a wxClientDC object, sets the font and text color, and draws the text on the device context. The wxDC class is part of the wxWidgets library package.