From fee71cd04d7e3a568fff7010c04e557401246873 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 14 May 2014 00:48:32 +0100 Subject: [PATCH] geometry tests --- dpf | 2 +- examples/demo.cpp | 44 ++++++++++++++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/dpf b/dpf index 6051bb2..e88ad41 160000 --- a/dpf +++ b/dpf @@ -1 +1 @@ -Subproject commit 6051bb2c1dc4368389f18e13b1a4275435460280 +Subproject commit e88ad4166548d774e96e7a1322c98f64ba08f2f8 diff --git a/examples/demo.cpp b/examples/demo.cpp index fca890f..9f54935 100644 --- a/examples/demo.cpp +++ b/examples/demo.cpp @@ -35,29 +35,45 @@ public: DummyWidget(Window& win) : Widget(win) { - l1.setStartPos(5, 5); - l2.setStartPos(5, 5+50); - l3.setStartPos(5, 5+100); - - l1.setEndPos(300-5, 5); - l2.setEndPos(300-5, 5+50); - l3.setEndPos(300-5, 5+100); } protected: void onDisplay() override { - glColor3f(0.3f, 0.5f, 0.8f); - l1.draw(); + glColor3f(0.302f, 0.337f, 0.361f); + bgFull.draw(); + + glColor3f(0.235f, 0.271f, 0.294f); + bgSmall.draw(); + + glColor3f(0.176f, 0.212f, 0.235f); + bgSmall.drawOutline(); + + glColor3f(0.302f*2, 0.337f*2, 0.361f*2); + tri.draw(); + } + + void onReshape(int width, int height) + { + // full bg + bgFull = DGL::Rectangle(0, 0, width, height); + + // small bg + bgSmall = DGL::Rectangle(20, 10, width-40, height-20); - glColor3f(0.5f, 0.8f, 0.3f); - l2.draw(); + // center triangle + tri = Triangle(width*0.5, height*0.1, width*0.1, height*0.9, width*0.9, height*0.9); - glColor3f(0.8f, 0.3f, 0.5f); - l3.draw(); + // make widget same size as window + setSize(width, height); + + // default reshape implementation + Widget::onReshape(width, height); } - Line l1, l2, l3; +private: + Rectangle bgFull, bgSmall; + Triangle tri; }; // ------------------------------------------------------