build fix
[LibreOffice.git] / slideshow / source / engine / transitions / figurewipe.cxx
blobcc9a2baa001417d80536fb5fb27e6b99a9f2a8d4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <basegfx/numeric/ftools.hxx>
22 #include <basegfx/matrix/b2dhommatrix.hxx>
23 #include <basegfx/point/b2dpoint.hxx>
24 #include <basegfx/matrix/b2dhommatrixtools.hxx>
25 #include "transitiontools.hxx"
26 #include "figurewipe.hxx"
29 namespace slideshow {
30 namespace internal {
32 ::basegfx::B2DPolyPolygon FigureWipe::operator () ( double t )
34 ::basegfx::B2DPolyPolygon res(m_figure);
35 res.transform(basegfx::tools::createScaleTranslateB2DHomMatrix(t, t, 0.5, 0.5));
36 return res;
39 FigureWipe * FigureWipe::createTriangleWipe()
41 const double s60 = sin( basegfx::deg2rad(60.0) );
42 const double s30 = sin( basegfx::deg2rad(30.0) );
43 ::basegfx::B2DPolygon figure;
44 figure.append( ::basegfx::B2DPoint( 0.5 + s30, 0.5 ) );
45 figure.append( ::basegfx::B2DPoint( 0.0, -0.5 - s60 ) );
46 figure.append( ::basegfx::B2DPoint( -0.5 - s30, 0.5 ) );
47 figure.setClosed(true);
48 return new FigureWipe(figure);
51 FigureWipe * FigureWipe::createArrowHeadWipe()
53 const double s60 = sin( basegfx::deg2rad(60.0) );
54 const double s30 = sin( basegfx::deg2rad(30.0) );
55 const double off = s30;
56 ::basegfx::B2DPolygon figure;
57 figure.append( ::basegfx::B2DPoint( 0.5 + s30 + off, 0.5 + off ) );
58 figure.append( ::basegfx::B2DPoint( 0.0, -0.5 - s60 ) );
59 figure.append( ::basegfx::B2DPoint( -0.5 - s30 - off, 0.5 + off ) );
60 figure.append( ::basegfx::B2DPoint( 0.0, 0.5 ) );
61 figure.setClosed(true);
62 return new FigureWipe(figure);
65 FigureWipe * FigureWipe::createPentagonWipe()
67 const double s = sin( basegfx::deg2rad(18.0) );
68 const double c = cos( basegfx::deg2rad(18.0) );
69 ::basegfx::B2DPolygon figure;
70 figure.append( ::basegfx::B2DPoint( 0.5, 0.5 ) );
71 figure.append( ::basegfx::B2DPoint( 0.5 + s, 0.5 - c ) );
72 figure.append( ::basegfx::B2DPoint( 0.0, 0.5 - c - sin(basegfx::deg2rad(36.0)) ) );
73 figure.append( ::basegfx::B2DPoint( -0.5 - s, 0.5 - c ) );
74 figure.append( ::basegfx::B2DPoint( -0.5, 0.5 ) );
75 figure.setClosed(true);
76 return new FigureWipe(figure);
79 FigureWipe * FigureWipe::createHexagonWipe()
81 const double s = sin( basegfx::deg2rad(30.0) );
82 const double c = cos( basegfx::deg2rad(30.0) );
83 ::basegfx::B2DPolygon figure;
84 figure.append( ::basegfx::B2DPoint( 0.5, c ) );
85 figure.append( ::basegfx::B2DPoint( 0.5 + s, 0.0 ) );
86 figure.append( ::basegfx::B2DPoint( 0.5, -c ) );
87 figure.append( ::basegfx::B2DPoint( -0.5, -c ) );
88 figure.append( ::basegfx::B2DPoint( -0.5 - s, 0.0 ) );
89 figure.append( ::basegfx::B2DPoint( -0.5, c ) );
90 figure.setClosed(true);
91 return new FigureWipe(figure);
94 FigureWipe * FigureWipe::createStarWipe( sal_Int32 nPoints )
96 const double v = (M_PI / nPoints);
97 const ::basegfx::B2DPoint p_( 0.0, -M_SQRT2 );
98 ::basegfx::B2DPolygon figure;
99 for ( sal_Int32 pos = 0; pos < nPoints; ++pos ) {
100 const double w = (pos * 2.0 * M_PI / nPoints);
101 ::basegfx::B2DHomMatrix aTransform;
102 ::basegfx::B2DPoint p(p_);
103 aTransform.rotate( -w );
104 p *= aTransform;
105 figure.append(p);
106 p = p_;
107 aTransform.identity();
108 aTransform.scale( 0.5, 0.5 );
109 aTransform.rotate( -w - v );
110 p *= aTransform;
111 figure.append(p);
113 figure.setClosed(true);
114 return new FigureWipe(figure);
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */