xcal
基于 C++23 的现代图形渲染引擎
载入中...
搜索中...
未找到
composedmobject.hpp
浏览该文件的文档.
1
11#pragma once
12#include <xcal/public.h>
13
18#include <xcal/property/vec.hpp>
19#include <xcmath/xcmath.hpp>
20
21namespace xcal::mobject {
22template <typename T>
24 protected:
26 public:
28 pos_ = pos;
29 return static_cast<T*>(this);
30 }
31 T* translate(float_t x, float_t y = 0, float_t z = 0) {
33 return static_cast<T*>(this);
34 }
35 const property::Vec<float_t, 3>& pos() const { return pos_; }
36};
37template <typename T>
39 protected:
41 public:
43 scale_ = scale;
44 return static_cast<T*>(this);
45 }
46 const property::Vec<float_t, 3>& scale() const { return scale_; }
49 return static_cast<T*>(this);
50 }
51 T* scale(float_t s) {
52 scale_ = scale_.value() * s;
53 return static_cast<T*>(this);
54 }
55
56 float_t scale_x() const { return scale_.value()[0]; }
57 float_t scale_y() const { return scale_.value()[1]; }
58 float_t scale_z() const { return scale_.value()[2]; }
59};
60template <typename T>
62 protected:
64 public:
67 return static_cast<T*>(this);
68 }
69 const property::Vec<float_t, 3>& rotation() const { return rotation_; }
70 T* rotate(float_t angle) {
71 rotation_.value().z() += angle;
72 return static_cast<T*>(this);
73 }
74};
75template <typename T>
77 protected:
78 property::Color stroke_color_{0.0, 0.0, 0.0, 1.0};
80 public:
82 stroke_color_ = color;
83 return static_cast<T*>(this);
84 }
87 return static_cast<T*>(this);
88 }
89 const property::Color& stroke_color() const { return stroke_color_; }
91 stroke_width_ = width;
92 return static_cast<T*>(this);
93 }
95 return stroke_width_;
96 }
97};
98template <typename T>
100 protected:
101 property::Color fill_color_{0.0, 0.0, 0.0, 1.0};
102 public:
104 fill_color_ = color;
105 return static_cast<T*>(this);
106 }
107 const property::Color& fill_color() const { return fill_color_; }
108};
109template <class T>
111 public ScalableMObject<T>,
112 public RotatableMObject<T> {
113 public:
118};
119
120template <typename _Derived, template <class> typename... _PropertyMObjects>
122 public _PropertyMObjects<_Derived>... {
123 public:
124 ComposedMObject() : _PropertyMObjects<_Derived>{}... {}
125};
126
127} // namespace xcal::mobject
抽象图形对象基类
图形对象命名空间
const property::Color & fill_color() const
property::Color fill_color_
填充颜色属性
T * set_fill_color(const property::Color::data_t &color)
T * translate(float_t x, float_t y=0, float_t z=0)
const property::Vec< float_t, 3 > & pos() const
T * set_pos(const property::Vec< float_t, 3 >::data_t &pos)
property::Vec< float_t, 3 > pos_
对象位置属性
property::Vec< float_t, 3 > rotation_
对象旋转属性
T * set_rotation(const property::Vec< float_t, 3 >::data_t &rotation)
const property::Vec< float_t, 3 > & rotation() const
const property::Vec< float_t, 3 > & scale() const
T * set_scale(const property::Vec< float_t, 3 >::data_t &scale)
property::Vec< float_t, 3 > scale_
对象缩放属性
T * scale(float_t x, float_t y, float_t z)
T * set_stroke_color(const property::Color::data_t &color)
property::Color stroke_color_
线条颜色属性
T * set_stroke_color(float_t r, float_t g, float_t b, float_t a=1.0)
const property::Scalar::data_t & stroke_width() const
T * set_stroke_width(property::Scalar::data_t width)
const property::Color & stroke_color() const
property::Scalar stroke_width_
线条宽度属性
颜色属性类
Definition color.hpp:16
data_t & value()
Definition vec.hpp:26
Vector class template
Definition vec.hpp:206
constexpr _Tp & z()
Get the item at index 2
Definition vec.hpp:476
float float_t
Definition public.h:27
#define XCAL_API
Definition public.h:69