updated licenses info
[platform/core/uifw/lottie-player.git] / src / vector / vbrush.cpp
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
3  *
4  * Licensed under the LGPL License, Version 2.1 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     https://www.gnu.org/licenses/
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "vbrush.h"
18
19 V_BEGIN_NAMESPACE
20
21 VGradient::VGradient(VGradient::Type type)
22     : mType(type),
23       mSpread(VGradient::Spread::Pad),
24       mMode(VGradient::Mode::Absolute)
25 {
26 }
27
28 void VGradient::setStops(const VGradientStops &stops)
29 {
30     mStops = stops;
31 }
32
33 VLinearGradient::VLinearGradient(const VPointF &start, const VPointF &stop)
34     : VGradient(VGradient::Type::Linear)
35 {
36     linear.x1 = start.x();
37     linear.y1 = start.y();
38     linear.x1 = stop.x();
39     linear.y1 = stop.y();
40 }
41
42 VLinearGradient::VLinearGradient(float xStart, float yStart, float xStop,
43                                  float yStop)
44     : VGradient(VGradient::Type::Linear)
45 {
46     linear.x1 = xStart;
47     linear.y1 = yStart;
48     linear.x1 = xStop;
49     linear.y1 = yStop;
50 }
51
52 VRadialGradient::VRadialGradient(const VPointF &center, float cradius,
53                                  const VPointF &focalPoint, float fradius)
54     : VGradient(VGradient::Type::Radial)
55 {
56     radial.cx = center.x();
57     radial.cy = center.y();
58     radial.fx = focalPoint.x();
59     radial.fy = focalPoint.y();
60     radial.cradius = cradius;
61     radial.fradius = fradius;
62 }
63
64 VRadialGradient::VRadialGradient(float cx, float cy, float cradius, float fx,
65                                  float fy, float fradius)
66     : VGradient(VGradient::Type::Radial)
67 {
68     radial.cx = cx;
69     radial.cy = cy;
70     radial.fx = fx;
71     radial.fy = fy;
72     radial.cradius = cradius;
73     radial.fradius = fradius;
74 }
75
76 VBrush::VBrush(const VColor &color) : mType(VBrush::Type::Solid), mColor(color)
77 {
78 }
79
80 VBrush::VBrush(int r, int g, int b, int a)
81     : mType(VBrush::Type::Solid), mColor(r, g, b, a)
82
83 {
84 }
85
86 VBrush::VBrush(const VGradient *gradient) : mType(VBrush::Type::NoBrush)
87 {
88     if (!gradient) return;
89
90     mGradient = gradient;
91
92     if (gradient->mType == VGradient::Type::Linear) {
93         mType = VBrush::Type::LinearGradient;
94     } else if (gradient->mType == VGradient::Type::Radial) {
95         mType = VBrush::Type::RadialGradient;
96     }
97 }
98
99 V_END_NAMESPACE