bezier.cpp
#include <smk/Color.hpp>
#include <smk/Shape.hpp>
#include <smk/Window.hpp>
int main() {
// Open a new window.
auto window = smk::Window(640, 480, "test");
window.ExecuteMainLoop([&] {
window.PoolEvents();
window.Clear(smk::Color::RGB(0.1f, 0.1f, 0.1f));
float y = 0.5f + 0.4f * sin(window.time());
// Draw a bezier path
auto bezier = smk::Shape::Bezier(
{
{10, 10},
{630 * y, 10},
{10, 480 * y},
{630, 480 * y},
},
50);
auto bezier_path_foreground = smk::Shape::Path(bezier, 10);
auto bezier_path_background = smk::Shape::Path(bezier, 20);
bezier_path_background.SetColor(smk::Color::Black);
bezier_path_foreground.SetColor(smk::Color::Yellow);
window.Draw(bezier_path_background);
window.Draw(bezier_path_foreground);
window.Display();
});
return EXIT_SUCCESS;
}
// Copyright 2019 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 Path(const std::vector< glm::vec2 > &points, float thickness)
Build a path of a given |thickness| along a sequence of connected lines. @params points The sequence ...
Definition: Shape.cpp:215
static std::vector< glm::vec2 > Bezier(const std::vector< glm::vec2 > &point, size_t subdivision)
Return a bezier curve.
Definition: Shape.cpp:193
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 Yellow
Yellow.
Definition: Color.cpp:35
glm::vec4 RGB(float red, float green, float blue)
Build an opaque color from its RGB components components.
Definition: Color.cpp:24