xcal
基于 C++23 的现代图形渲染引擎
载入中...
搜索中...
未找到
path.cc
浏览该文件的文档.
1#include <cmath>
2#include <cstddef>
7
8int main() {
9 auto scene = std::make_unique<xcal::scene::Scene>();
10 using namespace xcal::mobject;
11 using namespace xcal::property;
12
13 Path::data_t p(10);
14
15 for (size_t i = 0; i < p.size(); ++i) {
16 auto d = xcmath::radians(i * 360.0 / p.size());
17 p[i] = xcmath::vec2<float_t>{(float_t)cos(d), (float_t)sin(d)} *
18 ((i % 2) * 0.5f + 0.5f);
19 }
20
21 auto path = scene->add<Path>(Path::data_t{p}, false)
22 ->set_stroke_color({0, 1, 0, 1})
23 ->set_fill_color({0, 1, 1, 0.1});
24
25 auto render = xcal::render::opengl::OpenGLRender{scene.get()};
26 render.default_camera()
27 ->set_background_color(0.2, 0.2, 0.2, 1.0)
28 ->set_position(0, 0, 3);
29
30 render.show(1200, 675);
31 return 0;
32}
std::vector< vec > data_t
Definition path.hpp:16
Vector class template
Definition vec.hpp:206
int main()
Definition path.cc:8
Header file for mathematical functions
float float_t
Definition public.h:27
constexpr T radians(T degrees)
Convert degrees to radians
Definition function.hpp:25