update emoji autocorrect entries from po-files
[LibreOffice.git] / include / basegfx / tools / keystoplerp.hxx
blobbccfa3ab13bb36d68b454752a3e3bf63fe91833d
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 .
20 #ifndef INCLUDED_BASEGFX_TOOLS_KEYSTOPLERP_HXX
21 #define INCLUDED_BASEGFX_TOOLS_KEYSTOPLERP_HXX
23 #include <basegfx/numeric/ftools.hxx>
24 #include <vector>
25 #include <basegfx/basegfxdllapi.h>
27 namespace com{ namespace sun{ namespace star{ namespace uno {
28 template<typename T> class Sequence;
29 }}}}
31 namespace basegfx
33 namespace tools
35 /** Lerp in a vector of key stops
37 This class holds a key stop vector and provides the
38 functionality to lerp inside it. Useful e.g. for
39 multi-stop gradients, or the SMIL key time activity.
41 For those, given a global [0,1] lerp alpha, one need to
42 find the suitable bucket index from key stop vector, and
43 then calculate the relative alpha between the two buckets
44 found.
46 class BASEGFX_DLLPUBLIC KeyStopLerp
48 public:
49 typedef std::pair<std::ptrdiff_t,double> ResultType;
51 /** Create lerper with given vector of stops
53 @param rKeyStops
55 Vector of stops, must contain at least two elements
56 (though preferably more, otherwise you probably don't
57 need key stop lerping in the first place). All
58 elements must be of monotonically increasing value.
60 explicit KeyStopLerp( const std::vector<double>& rKeyStops );
62 /** Create lerper with given sequence of stops
64 @param rKeyStops
66 Sequence of stops, must contain at least two elements
67 (though preferably more, otherwise you probably don't
68 need key stop lerping in the first place). All
69 elements must be of monotonically increasing value.
71 explicit KeyStopLerp( const ::com::sun::star::uno::Sequence<double>& rKeyStops );
73 /** Find two nearest bucket index & interpolate
75 @param fAlpha
76 Find bucket index i, with keyStops[i] < fAlpha <=
77 keyStops[i+1]. Return new alpha value in [0,1),
78 proportional to fAlpha's position between keyStops[i]
79 and keyStops[i+1]
81 ResultType lerp(double fAlpha) const;
83 private:
84 std::vector<double> maKeyStops;
85 mutable std::ptrdiff_t mnLastIndex;
90 #endif
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */