rounded_rectangle.cpp
#include <algorithm>
#include <smk/Color.hpp>
#include <smk/Shape.hpp>
#include <smk/Window.hpp>
int main() {
auto window = smk::Window(640, 480, "test");
window.ExecuteMainLoop([&] {
window.PoolEvents();
window.Clear(smk::Color::Black);
smk::View view;
view.SetCenter(window.dimensions() * 0.5f);
view.SetSize(window.dimensions());
window.SetView(view);
float radius = std::min(window.width(), window.height()) * 0.5 *
(0.5 + 0.5 * sin(window.time() * 4.0));
float margin = 40.f;
auto rounded_rectangle = smk::Shape::RoundedRectangle(
window.width() - margin, window.height() - margin, radius);
rounded_rectangle.SetColor(smk::Color::Red);
rounded_rectangle.Move(window.dimensions() * 0.5f);
window.Draw(rounded_rectangle);
window.Display();
});
return EXIT_SUCCESS;
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.
static Transformable RoundedRectangle(float width, float height, float radius)
Return a rounded centered rectangle. @params width The width of the rectangle. @params height The hei...
Definition: Shape.cpp:309
void SetColor(const glm::vec4 &color)
Color.
void SetCenter(float x, float y)
Set the center position of the in-game view. param x The center of the view along the horizontal axis...
Definition: View.cpp:12
void SetSize(float width, float height)
Set the size of the in-game view. param width The size of the view along the horizontal axis....
Definition: View.cpp:26
A window. You can draw objects on the window.
Definition: Window.hpp:31
const glm::vec4 Black
Black.
Definition: Color.cpp:30
const glm::vec4 Red
Red.
Definition: Color.cpp:32