Kiwano Engine v1.2.x
Brush.h
1// Copyright (c) 2016-2018 Kiwano - Nomango
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19// THE SOFTWARE.
20
21#pragma once
22#include <kiwano/render/Color.h>
23#include <kiwano/render/NativeObject.h>
24#include <kiwano/render/Texture.h>
25
26namespace kiwano
27{
28
29KGE_DECLARE_SMART_PTR(Brush);
30
39{
40 float offset;
42
44
46};
47
52{
53 Clamp,
54 Wrap,
55 Mirror
56};
57
61{
64 Vector<GradientStop> stops;
66
68
69 LinearGradientStyle(const Point& begin, const Point& end, const Vector<GradientStop>& stops,
71};
72
76{
80 Vector<GradientStop> stops;
82
84
85 RadialGradientStyle(const Point& center, const Vec2& offset, const Vec2& radius, const Vector<GradientStop>& stops,
87};
88
93class KGE_API Brush : public NativeObject
94{
95public:
99 Brush(const Color& color);
100
104 Brush(const LinearGradientStyle& style);
105
109 Brush(const RadialGradientStyle& style);
110
111 Brush();
112
115 void SetColor(const Color& color);
116
119 void SetStyle(const LinearGradientStyle& style);
120
123 void SetStyle(const RadialGradientStyle& style);
124
127 void SetTexture(TexturePtr texture);
128
131 void SetTransform(const Transform& transform);
132
135 void SetTransform(const Matrix3x2& transform);
136
137public:
140 enum class Type
141 {
142 None,
143 SolidColor,
144 LinearGradient,
145 RadialGradient,
146 Texture
147 };
148
151 Type GetType() const;
152
153private:
154 Type type_;
155};
156
160{
161 return type_;
162}
163
164} // namespace kiwano
画刷
Definition: Brush.h:94
Type GetType() const
获取画刷类型
Definition: Brush.h:159
Type
画刷类型
Definition: Brush.h:141
Definition: Color.h:41
含有本地指针的对象
Definition: NativeObject.h:43
纹理
Definition: Texture.h:55
GradientExtendMode
渐变扩充模式
Definition: Brush.h:52
@ None
不启用抗锯齿
@ Clamp
夹模式,重复绘制边界颜色
@ Mirror
镜像模式,反转画笔内容
@ Wrap
包裹模式,重复画笔内容
渐变转换点
Definition: Brush.h:39
float offset
偏移距离
Definition: Brush.h:40
Color color
渐变点颜色
Definition: Brush.h:41
线性渐变样式
Definition: Brush.h:61
GradientExtendMode extend_mode
渐变扩充模式
Definition: Brush.h:65
Point begin
渐变起始点
Definition: Brush.h:62
Point end
渐变终止点
Definition: Brush.h:63
Vector< GradientStop > stops
渐变转换点集合
Definition: Brush.h:64
径向渐变样式
Definition: Brush.h:76
Vector< GradientStop > stops
渐变转换点集合
Definition: Brush.h:80
Point center
径向渐变圆心
Definition: Brush.h:77
Vec2 radius
径向渐变半径
Definition: Brush.h:79
Vec2 offset
径向渐变偏移
Definition: Brush.h:78
GradientExtendMode extend_mode
渐变扩充模式
Definition: Brush.h:81