Adding Visual namespace and Visual becomes Visual::Base
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / gradient / radial-gradient.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (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  * http://www.apache.org/licenses/LICENSE-2.0
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
18 #include "radial-gradient.h"
19
20 namespace Dali
21 {
22
23 namespace Toolkit
24 {
25
26 namespace Internal
27 {
28
29 RadialGradient::RadialGradient( const Vector2& center, float radius )
30 : Gradient()
31 {
32   SetCenterAndRadius( center, radius );
33 }
34
35 RadialGradient::~RadialGradient()
36 {}
37
38 void RadialGradient::SetCenterAndRadius( const Vector2& center, float radius )
39 {
40   mCenter = center;
41   mRadius = radius;
42
43   // Calculate the transform aligning to the circle
44   Matrix3 alignMatrix( mRadius, 0.f, 0.f, 0.f, mRadius, 0.f, mCenter.x, mCenter.y, 1.f );
45   alignMatrix.Invert();
46
47   mAlignmentTransform = alignMatrix;
48 }
49
50 const Vector2& RadialGradient::GetCenter() const
51 {
52   return mCenter;
53 }
54
55 float RadialGradient::GetRadius() const
56 {
57   return mRadius;
58 }
59
60 } // namespace Internal
61
62 } // namespace Toolkit
63
64 } // namespace Dali