brush.h
1/*
2** ClanLib SDK
3** Copyright (c) 1997-2020 The ClanLib Team
4**
5** This software is provided 'as-is', without any express or implied
6** warranty. In no event will the authors be held liable for any damages
7** arising from the use of this software.
8**
9** Permission is granted to anyone to use this software for any purpose,
10** including commercial applications, and to alter it and redistribute it
11** freely, subject to the following restrictions:
12**
13** 1. The origin of this software must not be misrepresented; you must not
14** claim that you wrote the original software. If you use this software
15** in a product, an acknowledgment in the product documentation would be
16** appreciated but is not required.
17** 2. Altered source versions must be plainly marked as such, and must not be
18** misrepresented as being the original software.
19** 3. This notice may not be removed or altered from any source distribution.
20**
21** Note: Some of the libraries ClanLib may link to may have additional
22** requirements or restrictions.
23**
24** File Author(s):
25**
26** Magnus Norddahl
27** Mark Page
28*/
29
30#pragma once
31
32#include "../../Core/Math/mat3.h"
33#include "../../Display/2D/color.h"
34#include "image.h"
35#include <vector>
36
37namespace clan
38{
40 {
41 public:
44
46 float position = 0.0f;
47 };
48
49 enum class BrushType
50 {
51 solid,
52 linear,
53 radial,
54 image
55 };
56
57 enum class BrushWrapMode
58 {
59 clamp,
60 wrap,
61 mirror
62 };
63
65 {
66 nearest,
67 linear
68 };
69
70 class Brush
71 {
72 public:
73 Brush() { }
74 Brush(const Colorf &color) : color(color) { }
75
77
78 // Generic brush properties
79 float opacity = 1.0f;
81
82 // Solid color
84
85 // Gradient color stops
86 std::vector<BrushGradientStop> stops;
87
88 // Linear gradient
91
92 // Radial gradient
95 float radius_x = 0.0f;
96 float radius_y = 0.0f;
97
98 // Texture
103
104 static Brush solid(float r, float g, float b, float a = 1.0f)
105 {
106 Brush brush;
107 brush.color = Colorf(r, g, b, a);
108 return brush;
109 }
110 static Brush solid(const Colorf &color)
111 {
112 Brush brush;
113 brush.color = color;
114 return brush;
115 }
116 static Brush solid_rgb8(int r, int g, int b)
117 {
118 Brush brush;
119 brush.color = Colorf(r, g, b);
120 return brush;
121 }
122
123 static Brush solid_rgba8(int r, int g, int b, int a)
124 {
125 Brush brush;
126 brush.color = Colorf(r, g, b, a);
127 return brush;
128 }
129 };
130
131}
Definition brush.h:40
float position
Definition brush.h:46
BrushGradientStop()
Definition brush.h:42
Colorf color
Definition brush.h:45
BrushGradientStop(const Colorf &color, float position)
Definition brush.h:43
Definition brush.h:71
static Brush solid(float r, float g, float b, float a=1.0f)
Definition brush.h:104
Pointf gradient_origin_offset
Definition brush.h:94
Mat3f transform
Definition brush.h:80
Brush(const Colorf &color)
Definition brush.h:74
Pointf center_point
Definition brush.h:93
float opacity
Definition brush.h:79
BrushType type
Definition brush.h:76
static Brush solid(const Colorf &color)
Definition brush.h:110
Brush()
Definition brush.h:73
Pointf start_point
Definition brush.h:89
Image image
Definition brush.h:99
std::vector< BrushGradientStop > stops
Definition brush.h:86
static Brush solid_rgba8(int r, int g, int b, int a)
Definition brush.h:123
float radius_x
Definition brush.h:95
BrushInterpolateMode interpolate
Definition brush.h:102
Colorf color
Definition brush.h:83
Pointf end_point
Definition brush.h:90
BrushWrapMode wrap_y
Definition brush.h:101
BrushWrapMode wrap_x
Definition brush.h:100
float radius_y
Definition brush.h:96
static Brush solid_rgb8(int r, int g, int b)
Definition brush.h:116
Floating point color description class (for float).
Definition color.h:799
Image class.
Definition image.h:59
2D (x,y) point structure - Float
Definition point.h:72
static Mat3< float > identity()
Definition mat3.h:365
Definition clanapp.h:36
BrushInterpolateMode
Definition brush.h:65
BrushType
Definition brush.h:50
BrushWrapMode
Definition brush.h:58