Kiwano Engine v1.3.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/platform/NativeObject.hpp>
23#include <kiwano/render/Color.h>
24#include <kiwano/render/Texture.h>
25
26namespace kiwano
27{
28
37{
38 float offset;
40
42
44};
45
50{
51 Clamp,
52 Wrap,
53 Mirror
54};
55
59{
62 Vector<GradientStop> stops;
64
66
67 LinearGradientStyle(const Point& begin, const Point& end, const Vector<GradientStop>& stops,
69};
70
74{
78 Vector<GradientStop> stops;
80
82
83 RadialGradientStyle(const Point& center, const Vec2& offset, const Vec2& radius, const Vector<GradientStop>& stops,
85};
86
91class KGE_API Brush : public NativeObject
92{
93public:
97 Brush(const Color& color);
98
102 Brush(const LinearGradientStyle& style);
103
107 Brush(const RadialGradientStyle& style);
108
109 Brush();
110
113 void SetColor(const Color& color);
114
117 void SetStyle(const LinearGradientStyle& style);
118
121 void SetStyle(const RadialGradientStyle& style);
122
125 void SetTexture(RefPtr<Texture> texture);
126
129 void SetTransform(const Transform& transform);
130
133 void SetTransform(const Matrix3x2& transform);
134
135public:
138 enum class Type
139 {
140 None,
141 SolidColor,
142 LinearGradient,
143 RadialGradient,
144 Texture
145 };
146
149 Type GetType() const;
150
151private:
152 Type type_;
153};
154
158{
159 return type_;
160}
161
162} // namespace kiwano
画刷
Definition: Brush.h:92
Type GetType() const
获取画刷类型
Definition: Brush.h:157
Type
画刷类型
Definition: Brush.h:139
Definition: Color.h:41
含有本地指针的对象
Definition: NativeObject.hpp:32
引用计数智能指针
Definition: RefBasePtr.hpp:35
纹理
Definition: Texture.h:64
GradientExtendMode
渐变扩充模式
Definition: Brush.h:50
@ None
不启用抗锯齿
@ Clamp
夹模式,重复绘制边界颜色
@ Mirror
镜像模式,反转画笔内容
@ Wrap
包裹模式,重复画笔内容
渐变转换点
Definition: Brush.h:37
float offset
偏移距离
Definition: Brush.h:38
Color color
渐变点颜色
Definition: Brush.h:39
线性渐变样式
Definition: Brush.h:59
GradientExtendMode extend_mode
渐变扩充模式
Definition: Brush.h:63
Point begin
渐变起始点
Definition: Brush.h:60
Point end
渐变终止点
Definition: Brush.h:61
Vector< GradientStop > stops
渐变转换点集合
Definition: Brush.h:62
径向渐变样式
Definition: Brush.h:74
Vector< GradientStop > stops
渐变转换点集合
Definition: Brush.h:78
Point center
径向渐变圆心
Definition: Brush.h:75
Vec2 radius
径向渐变半径
Definition: Brush.h:77
Vec2 offset
径向渐变偏移
Definition: Brush.h:76
GradientExtendMode extend_mode
渐变扩充模式
Definition: Brush.h:79