diff --git a/dependencies/testproject_featuredemo.cpp b/dependencies/testproject_featuredemo.cpp index be49071c71b58a68f25b0fd8fe6199a8ef17157b..88ee0113d8df77785618625e800cd1ea38b6427e 100644 --- a/dependencies/testproject_featuredemo.cpp +++ b/dependencies/testproject_featuredemo.cpp @@ -48,11 +48,13 @@ void textChanged() { std::cout << "The input text is now: " << input.getText() << std::endl; } - TDT4102::Slider s{{200, 300}, 200, 100, 0, 100, 0}; + TDT4102::Slider rv{{200, 300}, 300, 80}; + TDT4102::Slider gv{{200, 420}, 300, 80, 0, 255, 7}; + TDT4102::Slider bv{{200, 540}, 300, 80, 0, 255, 240}; -void sliderValue() { - std::cout << "Value is: " << s.getValue() << std::endl; -} +// void sliderValue() { +// std::cout << "Value is: " << s.getValue() << std::endl; +// } int main(int argc, char* argv[]) { TDT4102::AnimationWindow window(100, 100, 1000, 800, "Test"); @@ -75,12 +77,18 @@ int main(int argc, char* argv[]) { input.setCallback(&textChanged); window.add(input); - s.setSliderCursorColor(TDT4102::Color::lime_green); - s.setSliderCursorColorHover(TDT4102::Color::lime_green); - s.setSliderBarColorFilled(TDT4102::Color::pink); + rv.setCallback([&window] {window.setBackgroundColor(TDT4102::Color(rv.getValue(), gv.getValue(), bv.getValue()));}); + gv.setCallback([&window] {window.setBackgroundColor(TDT4102::Color(rv.getValue(), gv.getValue(), bv.getValue()));}); + bv.setCallback([&window] {window.setBackgroundColor(TDT4102::Color(rv.getValue(), gv.getValue(), bv.getValue()));}); + + // s.setSliderCursorColor(TDT4102::Color::lime_green); + // s.setSliderCursorColorHover(TDT4102::Color::lime_green); + // s.setSliderBarColorFilled(TDT4102::Color::pink); - s.setCallback(&sliderValue); - window.add(s); + // s.setCallback(&sliderValue); + window.add(rv); + window.add(bv); + window.add(gv); int x = 10; int y = 10; @@ -94,8 +102,8 @@ int main(int argc, char* argv[]) { std::vector<Ball> circles; circles.resize(5000); for (unsigned int i = 0; i < circles.size(); i++) { - circles.at(i).x = randint(0, window.get_width()); - circles.at(i).y = randint(0, window.get_height()); + circles.at(i).x = randint(0, window.width()); + circles.at(i).y = randint(0, window.height()); circles.at(i).radius = randint(5, 10); circles.at(i).xSpeed = float(randint(-400, 400)) / 100.0f; circles.at(i).ySpeed = float(randint(-400, 400)) / 100.0f; @@ -124,8 +132,8 @@ int main(int argc, char* argv[]) { // window.draw_image(mousePosition, image); bool allAtCenter = true; for (Ball& ball : circles) { - float gravityX = (float(window.get_width()) / 2.0f) - ball.x; - float gravityY = (float(window.get_height()) / 2.0f) - ball.y; + float gravityX = (float(window.width()) / 2.0f) - ball.x; + float gravityY = (float(window.height()) / 2.0f) - ball.y; float absoluteSpeed = std::max(std::sqrt(gravityX * gravityX + gravityY * gravityY), 3.0f); const float gravity = 0.07f; ball.xSpeed += (gravityX / absoluteSpeed) * gravity; @@ -144,7 +152,7 @@ int main(int argc, char* argv[]) { } else if(ball.y + ball.radius < 0) { ball.y = window.h() + ball.radius; }*/ - if ((std::abs(ball.x - float(window.get_width()) / 2.0f) > 1.0f) && (std::abs(ball.y - float(window.get_height()) / 2.0f) > 1.0f)) { + if ((std::abs(ball.x - float(window.width()) / 2.0f) > 1.0f) && (std::abs(ball.y - float(window.height()) / 2.0f) > 1.0f)) { allAtCenter = false; } // window.draw_circle({int(ball.x), int(ball.y)}, ball.radius, ball.colour, TDT4102::Color::black);