Someguy384728

Other code

Jun 8th, 2022
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. #include "wx/wx.h"
  2. #include "wx/dcbuffer.h"
  3. #include "vector"
  4. using namespace std;
  5.  
  6.  
  7. class MyFrame : public wxFrame {
  8. public:
  9. wxPen blackPen3;
  10. wxColor brown;
  11. wxColor yellow;
  12. wxColor blue;
  13. wxBrush brownBrush;
  14. wxBrush yellowBrush;
  15. wxBrush blueBrush;
  16. wxBrush *wxBROWN_BRUSH;
  17. vector<wxPoint> mountainPeaks;
  18. MyFrame (const wxString& title) : wxFrame(nullptr, wxID_ANY, title, wxPoint(50,50), wxSize(640,500)){
  19. SetBackgroundStyle (wxBG_STYLE_PAINT);
  20. blackPen3 = wxPen(*wxBLACK);
  21. blackPen3.SetWidth (3);
  22. brown = wxColor (165,42,42);
  23. yellow = wxColor (255,255,0);
  24. blue = wxColor (0,0,255);
  25. brownBrush= wxBrush(brown);
  26. yellowBrush= wxBrush(yellow);
  27. blueBrush= wxBrush(blue);
  28. *wxBROWN_BRUSH= wxBrush(brown);
  29. mountainPeaks = vector<wxPoint> {wxPoint(640,0), wxPoint(540,40),wxPoint(600,55),wxPoint(520,85),wxPoint(600,100),wxPoint(560,120),wxPoint(640,150)};
  30. Bind(wxEVT_PAINT, &MyFrame :: OnPaint,this);
  31. Bind(wxEVT_CLOSE_WINDOW, &MyFrame ::OnClose, this);
  32. }
  33.  
  34.  
  35.  
  36. void OnClose (wxCloseEvent& event){
  37. Destroy();
  38. }
  39. void OnPaint(wxPaintEvent &event){
  40. wxAutoBufferedPaintDC dc(this);
  41. dc.SetBackground(blueBrush);
  42. dc.Clear();
  43. dc.SetPen(blackPen3);
  44. dc.SetBrush(*wxYELLOW_BRUSH);
  45. dc.DrawEllipse(wxPoint(0,500), wxSize(70,70));
  46. dc.SetBrush(*wxBROWN_BRUSH);
  47. dc.DrawPolygon(mountainPeaks.size(), mountainPeaks.data());
  48. }
  49. };
  50.  
  51. class MyApp : public wxApp{
  52. public:
  53. virtual bool OnInit(){
  54. MyFrame *frame = new MyFrame (wxT("mountains"));
  55. frame->Show(true);
  56. return true;
  57. }
  58. };
  59. IMPLEMENT_APP(MyApp)
  60.  
Advertisement
Add Comment
Please, Sign In to add comment