#include "CarnegieMellonGraphics.h" #include #include #include #include #include const double pi = 3.1415926; using namespace std; void WaitNClear(Window &inputWindow); // drawing tests: void testDrawArc1(Window &test); void testDrawBezierCurve1(Window &test); void testDrawChordFilled1(Window &test); void testDrawChordOutline1(Window &test); void testDrawCircleFilled1(Window &test); void testDrawCircleOutline1(Window &test); // not done: void testDrawEllipseFilled1(Window &test); void testDrawEllipseOutline1(Window &test); int main() { Window test(640,480,"test"); test.enableAntialiasing(); testDrawArc1(test); WaitNClear(test); testDrawBezierCurve1(test); WaitNClear(test); testDrawChordFilled1(test); WaitNClear(test); testDrawChordOutline1(test); WaitNClear(test); /* testDrawCircleOutline1(test); WaitNClear(test); testDrawCircleFilled1(test); WaitNClear(test); */ return 0; } vector toVector(int a, int b, int c, int d) { vector temp; temp.push_back(a); temp.push_back(b); temp.push_back(c); temp.push_back(d); return temp; } void WaitNClear(Window &inputWindow) { Font f(Font::HELVETICA, 18); inputWindow.drawText(Style::BLACK, f, inputWindow.getWidth()/2 - 100, inputWindow.getHeight() - 25, "Click mouse to continue..."); // Flush the mouse queue inputWindow.flushMouseQueue(); // Ignore return value since we don't care what type of click it was while (inputWindow.waitForMouseEvent() != MouseEvent(MouseEvent::BUTTON_CLICK_EVENT)) {} // Draw a rectangle that covers the entire window inputWindow.drawRectangleFilled(Style::WHITE, 0, 0, inputWindow.getWidth(), inputWindow.getHeight()); } ///////////////////////////////////////////////////////////////////////////////////// void testDrawArc1(Window &test) { test.drawArc(Style::RED, 0, 0, 100, 100, 0, 90); test.drawArc(Style::BLUE, 100, 0, 200, 100, 90, 270); test.drawArc(Style::GREEN, 0, 100, 100, 200, 45, 135); test.drawArc(Style::BLACK, 100, 100, 200, 200, 180, 90); test.drawArc(Style(Color(255,0,255)), 50, 50, 500, 400, 10, 350); } void testDrawBezierCurve1(Window &test) { //5, 10, 5, 470, 10, 5, 470, 5; test.drawBezierCurve(Style(Color(255,0,255),5), toVector(5, 5, 10, 470), toVector(10, 470, 5, 5)); //15, 24, 200, 470, 300, 100, 560, 400 test.drawBezierCurve(Style(Color::BLACK), toVector(15, 200, 300, 560), toVector(24, 470, 100, 400)); //500, 10, 630, 470, 300, 300, 10, 10 test.drawBezierCurve(Style(Color(10, 10, 200)), toVector(500, 630, 300, 10), toVector(10, 470, 300, 10)); } void testDrawChordFilled1(Window &test) { test.drawChordFilled(Style(Color(255,0,255)), 50, 50, 500, 400, 0, 45); test.drawChordFilled(Style::RED, 0, 0, 100, 100, 0, 90); test.drawChordFilled(Style::BLUE, 100, 0, 200, 100, 90, 270); test.drawChordFilled(Style::GREEN, 0, 100, 100, 200, 45, 135); test.drawChordFilled(Style::BLACK, 100, 100, 200, 200, 180, 90); } void testDrawChordOutline1(Window &test) { test.drawChordOutline(Style(Color(255,0,255)), 50, 50, 500, 400, 0, 45); test.drawChordOutline(Style::RED, 0, 0, 100, 100, 0, 90); test.drawChordOutline(Style::BLUE, 100, 0, 200, 100, 90, 270); test.drawChordOutline(Style::GREEN, 0, 100, 100, 200, 45, 135); test.drawChordOutline(Style::BLACK, 100, 100, 200, 200, 180, 90); } void testDrawCircleFilled1(Window &test) { test.drawCircleFilled(Style(Color(20,50,0)), 320, 240, 200); test.drawCircleFilled(Style::RED, 50, 50, 50); test.drawCircleFilled(Style::BLUE, 50, 50, 25); test.drawCircleFilled(Style::GREEN, 75, 75, 25); } void testDrawCircleOutline1(Window &test) { test.drawCircleOutline(Style(Color(20,50,0),7), 320, 240, 200); test.drawCircleOutline(Style::RED, 50, 50, 50); test.drawCircleOutline(Style::BLUE, 50, 50, 25); test.drawCircleOutline(Style::GREEN, 75, 75, 25); }