b5a3eb4d82fc2424ad71d4be382786057f056309
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / text-abstraction / text-renderer-layout-helper.cpp
1 /*
2  * Copyright (c) 2019 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 // FILE HEADER
19 #include <dali/devel-api/text-abstraction/text-renderer-layout-helper.h>
20
21 // EXTERNAL INCLUDES
22 #include <cmath>
23
24 namespace Dali
25 {
26
27 namespace TextAbstraction
28 {
29
30 void TransformToArcClockwise( const CircularTextParameters& parameters, double& x, double& y )
31 {
32   double radius = parameters.radius;
33   double angle = parameters.beginAngle;
34
35   angle -= parameters.invRadius * x;
36
37   radius -= y;
38   x =  radius * cos( angle );
39   y = -radius * sin( angle );
40
41   x += parameters.centerX;
42   y += parameters.centerY;
43 }
44
45 void TransformToArcAntiClockwise( const CircularTextParameters& parameters, double& x, double& y )
46 {
47   double radius = parameters.radius;
48   double angle = parameters.beginAngle;
49
50   angle += parameters.invRadius * x;
51
52   radius += y;
53   x = radius * cos( angle );
54   y = radius * sin( -angle );
55
56   x += parameters.centerX;
57   y += parameters.centerY;
58 }
59
60 } // namespace TextAbstraction
61
62 } // namespace Dali