LibreOffice Module slideshow (master) 1
figurewipe.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
25#include "figurewipe.hxx"
26
27
28namespace slideshow::internal {
29
31{
34 return res;
35}
36
37std::shared_ptr<FigureWipe> FigureWipe::createTriangleWipe()
38{
39 const double s60 = sin( basegfx::deg2rad(60.0) );
40 const double s30 = sin( basegfx::deg2rad(30.0) );
42 figure.append( ::basegfx::B2DPoint( 0.5 + s30, 0.5 ) );
43 figure.append( ::basegfx::B2DPoint( 0.0, -0.5 - s60 ) );
44 figure.append( ::basegfx::B2DPoint( -0.5 - s30, 0.5 ) );
45 figure.setClosed(true);
46 return std::make_shared<FigureWipe>(figure);
47}
48
49std::shared_ptr<FigureWipe> FigureWipe::createArrowHeadWipe()
50{
51 const double s60 = sin( basegfx::deg2rad(60.0) );
52 const double s30 = sin( basegfx::deg2rad(30.0) );
53 const double off = s30;
55 figure.append( ::basegfx::B2DPoint( 0.5 + s30 + off, 0.5 + off ) );
56 figure.append( ::basegfx::B2DPoint( 0.0, -0.5 - s60 ) );
57 figure.append( ::basegfx::B2DPoint( -0.5 - s30 - off, 0.5 + off ) );
58 figure.append( ::basegfx::B2DPoint( 0.0, 0.5 ) );
59 figure.setClosed(true);
60 return std::make_shared<FigureWipe>(figure);
61}
62
63std::shared_ptr<FigureWipe> FigureWipe::createPentagonWipe()
64{
65 const double s = sin( basegfx::deg2rad(18.0) );
66 const double c = cos( basegfx::deg2rad(18.0) );
68 figure.append( ::basegfx::B2DPoint( 0.5, 0.5 ) );
69 figure.append( ::basegfx::B2DPoint( 0.5 + s, 0.5 - c ) );
70 figure.append( ::basegfx::B2DPoint( 0.0, 0.5 - c - sin(basegfx::deg2rad(36.0)) ) );
71 figure.append( ::basegfx::B2DPoint( -0.5 - s, 0.5 - c ) );
72 figure.append( ::basegfx::B2DPoint( -0.5, 0.5 ) );
73 figure.setClosed(true);
74 return std::make_shared<FigureWipe>(figure);
75}
76
77std::shared_ptr<FigureWipe> FigureWipe::createHexagonWipe()
78{
79 const double s = sin( basegfx::deg2rad(30.0) );
80 const double c = cos( basegfx::deg2rad(30.0) );
82 figure.append( ::basegfx::B2DPoint( 0.5, c ) );
83 figure.append( ::basegfx::B2DPoint( 0.5 + s, 0.0 ) );
84 figure.append( ::basegfx::B2DPoint( 0.5, -c ) );
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.setClosed(true);
89 return std::make_shared<FigureWipe>(figure);
90}
91
92std::shared_ptr<FigureWipe> FigureWipe::createStarWipe( sal_Int32 nPoints )
93{
94 const double v = M_PI / nPoints;
95 const ::basegfx::B2DPoint p_( 0.0, -M_SQRT2 );
97 for ( sal_Int32 pos = 0; pos < nPoints; ++pos ) {
98 const double w = pos * 2.0 * M_PI / nPoints;
99 ::basegfx::B2DHomMatrix aTransform;
101 aTransform.rotate( -w );
102 p *= aTransform;
103 figure.append(p);
104 p = p_;
105 aTransform.identity();
106 aTransform.scale( 0.5, 0.5 );
107 aTransform.rotate( -w - v );
108 p *= aTransform;
109 figure.append(p);
110 }
111 figure.setClosed(true);
112 return std::make_shared<FigureWipe>(figure);
113}
114
115}
116
117/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XPropertyListType t
void rotate(double fRadiant)
void scale(double fX, double fY)
void transform(const basegfx::B2DHomMatrix &rMatrix)
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
void setClosed(bool bNew)
static std::shared_ptr< FigureWipe > createTriangleWipe()
Definition: figurewipe.cxx:37
virtual ::basegfx::B2DPolyPolygon operator()(double t) override
Retrieve the poly-polygon for value t.
Definition: figurewipe.cxx:30
const ::basegfx::B2DPolygon m_figure
Definition: figurewipe.hxx:42
static std::shared_ptr< FigureWipe > createPentagonWipe()
Definition: figurewipe.cxx:63
static std::shared_ptr< FigureWipe > createStarWipe(sal_Int32 nPoints)
Definition: figurewipe.cxx:92
static std::shared_ptr< FigureWipe > createHexagonWipe()
Definition: figurewipe.cxx:77
static std::shared_ptr< FigureWipe > createArrowHeadWipe()
Definition: figurewipe.cxx:49
float v
void * p
B2DHomMatrix createScaleTranslateB2DHomMatrix(double fScaleX, double fScaleY, double fTranslateX, double fTranslateY)
constexpr double deg2rad(double v)
sal_Int32 w
size_t pos