Created
April 11, 2015 04:23
-
-
Save bewuethr/28b5baaa57f645e7ed4c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Chapter 12, exercise 01: draw rectangle as Rectangle and Polygon | |
#include "../lib_files/Simple_window.h" | |
#include "../lib_files/Graph.h" | |
// draw rectangle as Rectangle (blue) and as Polygon (red) | |
void ex01(Simple_window& win) | |
{ | |
Graph_lib::Rectangle rect(Point(100,100),150,100); | |
rect.set_color(Color::blue); | |
win.attach(rect); | |
Graph_lib::Polygon polyg; | |
polyg.add(Point(100,250)); | |
polyg.add(Point(250,250)); | |
polyg.add(Point(250,300)); | |
polyg.add(Point(100,300)); | |
polyg.set_color(Color::red); | |
win.attach(polyg); | |
win.wait_for_button(); | |
} | |
int main() | |
try { | |
Point p(100,100); | |
Simple_window win(p,1400,800,"My window"); | |
ex01(win); | |
} | |
catch (exception& e) { | |
cerr << "exception: " << e.what() << endl; | |
keep_window_open(); | |
} | |
catch (...) { | |
cerr << "exception\n"; | |
keep_window_open(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment