bump product version to 5.0.4.1
[LibreOffice.git] / slideshow / source / engine / transitions / figurewipe.cxx
blob331b1cece82a97108af7708d2737ac7342f4e7a0
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 <canvas/debug.hxx>
22 #include <basegfx/numeric/ftools.hxx>
23 #include <basegfx/matrix/b2dhommatrix.hxx>
24 #include <basegfx/point/b2dpoint.hxx>
25 #include <basegfx/matrix/b2dhommatrixtools.hxx>
26 #include "transitiontools.hxx"
27 #include "figurewipe.hxx"
30 namespace slideshow {
31 namespace internal {
33 ::basegfx::B2DPolyPolygon FigureWipe::operator () ( double t )
35 ::basegfx::B2DPolyPolygon res(m_figure);
36 res.transform(basegfx::tools::createScaleTranslateB2DHomMatrix(t, t, 0.5, 0.5));
37 return res;
40 FigureWipe * FigureWipe::createTriangleWipe()
42 const double s60 = sin( basegfx::deg2rad(60.0) );
43 const double s30 = sin( basegfx::deg2rad(30.0) );
44 ::basegfx::B2DPolygon figure;
45 figure.append( ::basegfx::B2DPoint( 0.5 + s30, 0.5 ) );
46 figure.append( ::basegfx::B2DPoint( 0.0, -0.5 - s60 ) );
47 figure.append( ::basegfx::B2DPoint( -0.5 - s30, 0.5 ) );
48 figure.setClosed(true);
49 return new FigureWipe(figure);
52 FigureWipe * FigureWipe::createArrowHeadWipe()
54 const double s60 = sin( basegfx::deg2rad(60.0) );
55 const double s30 = sin( basegfx::deg2rad(30.0) );
56 const double off = s30;
57 ::basegfx::B2DPolygon figure;
58 figure.append( ::basegfx::B2DPoint( 0.5 + s30 + off, 0.5 + off ) );
59 figure.append( ::basegfx::B2DPoint( 0.0, -0.5 - s60 ) );
60 figure.append( ::basegfx::B2DPoint( -0.5 - s30 - off, 0.5 + off ) );
61 figure.append( ::basegfx::B2DPoint( 0.0, 0.5 ) );
62 figure.setClosed(true);
63 return new FigureWipe(figure);
66 FigureWipe * FigureWipe::createPentagonWipe()
68 const double s = sin( basegfx::deg2rad(18.0) );
69 const double c = cos( basegfx::deg2rad(18.0) );
70 ::basegfx::B2DPolygon figure;
71 figure.append( ::basegfx::B2DPoint( 0.5, 0.5 ) );
72 figure.append( ::basegfx::B2DPoint( 0.5 + s, 0.5 - c ) );
73 figure.append( ::basegfx::B2DPoint( 0.0, 0.5 - c - sin(basegfx::deg2rad(36.0)) ) );
74 figure.append( ::basegfx::B2DPoint( -0.5 - s, 0.5 - c ) );
75 figure.append( ::basegfx::B2DPoint( -0.5, 0.5 ) );
76 figure.setClosed(true);
77 return new FigureWipe(figure);
80 FigureWipe * FigureWipe::createHexagonWipe()
82 const double s = sin( basegfx::deg2rad(30.0) );
83 const double c = cos( basegfx::deg2rad(30.0) );
84 ::basegfx::B2DPolygon figure;
85 figure.append( ::basegfx::B2DPoint( 0.5, c ) );
86 figure.append( ::basegfx::B2DPoint( 0.5 + s, 0.0 ) );
87 figure.append( ::basegfx::B2DPoint( 0.5, -c ) );
88 figure.append( ::basegfx::B2DPoint( -0.5, -c ) );
89 figure.append( ::basegfx::B2DPoint( -0.5 - s, 0.0 ) );
90 figure.append( ::basegfx::B2DPoint( -0.5, c ) );
91 figure.setClosed(true);
92 return new FigureWipe(figure);
95 FigureWipe * FigureWipe::createStarWipe( sal_Int32 nPoints )
97 const double v = (M_PI / nPoints);
98 const ::basegfx::B2DPoint p_( 0.0, -M_SQRT2 );
99 ::basegfx::B2DPolygon figure;
100 for ( sal_Int32 pos = 0; pos < nPoints; ++pos ) {
101 const double w = (pos * 2.0 * M_PI / nPoints);
102 ::basegfx::B2DHomMatrix aTransform;
103 ::basegfx::B2DPoint p(p_);
104 aTransform.rotate( -w );
105 p *= aTransform;
106 figure.append(p);
107 p = p_;
108 aTransform.identity();
109 aTransform.scale( 0.5, 0.5 );
110 aTransform.rotate( -w - v );
111 p *= aTransform;
112 figure.append(p);
114 figure.setClosed(true);
115 return new FigureWipe(figure);
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */