1 /*
2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
3
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
13
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 #include "vbrush.h"
24
25 V_BEGIN_NAMESPACE
26
VGradient(VGradient::Type type)27 VGradient::VGradient(VGradient::Type type)
28 : mType(type)
29 {
30 if (mType == Type::Linear)
31 linear.x1 = linear.y1 = linear.x2 = linear.y2 = 0.0f;
32 else
33 radial.cx = radial.cy = radial.fx =
34 radial.fy = radial.cradius = radial.fradius = 0.0f;
35 }
36
setStops(const VGradientStops & stops)37 void VGradient::setStops(const VGradientStops &stops)
38 {
39 mStops = stops;
40 }
41
VBrush(const VColor & color)42 VBrush::VBrush(const VColor &color) : mType(VBrush::Type::Solid), mColor(color)
43 {
44 }
45
VBrush(uchar r,uchar g,uchar b,uchar a)46 VBrush::VBrush(uchar r, uchar g, uchar b, uchar a)
47 : mType(VBrush::Type::Solid), mColor(r, g, b, a)
48
49 {
50 }
51
VBrush(const VGradient * gradient)52 VBrush::VBrush(const VGradient *gradient)
53 {
54 if (!gradient) return;
55
56 mGradient = gradient;
57
58 if (gradient->mType == VGradient::Type::Linear) {
59 mType = VBrush::Type::LinearGradient;
60 } else if (gradient->mType == VGradient::Type::Radial) {
61 mType = VBrush::Type::RadialGradient;
62 }
63 }
64
VBrush(const VTexture * texture)65 VBrush::VBrush(const VTexture *texture):mType(VBrush::Type::Texture), mTexture(texture)
66 {
67 }
68
69 V_END_NAMESPACE
70