New Upstream Snapshot - tweeny
Ready changes
Summary
Merged new upstream version: 3.2.0+git20210919.1.bfec586 (was: 3).
Resulting package
Built on 2022-10-22T21:37 (took 8m46s)
The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:
apt install -t fresh-snapshots libtweeny-dev
Lintian Result
Diff
diff --git a/.gitignore b/.gitignore
index 1c85d0e..f3aff03 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
.idea
cmake-build-*
+build
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fa625b6..2e4ae9c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,9 +1,35 @@
# Tweeny Changelog
+- Version 3.2.1
+ - Adds `<string>` as dependency
+
+- Version 3.2.0
+ - Fixed installation on other than Ubuntu distributions. (@xvitaly)
+ - Consider interpolation duration in the right place (fix #19)
+ - Fixes compilation error when using the `jump` function (fix #21)
+ - Small code and documentation improvements
+ - **New feature**: allows easing selection (`via()`) using `easing::enumerated` or `std::string`:
+ ```
+ tweeny::from(0.0f).to(1.0f).during(100).via(easing::enumerated::linear);
+ tweeny::from(0.0f).to(1.0f).during(100).via("linear");
+ ```
+
+- Version 3.1.1
+ - Remove unused CMake options
+ - Adds a single header version
+
+- Version 3.1.0:
+ - From now on, tweeny will be using a more traditional versioning scheme
+ - Remove some extraneous semicolons (@Omegastick)
+ - Adds `easing::stepped` and `easing::def` for arithmetic-like values (@ArnCarveris)
+ - Fix point progress calculation in multi-duration tweens (#15)
+ - Fix deduction of same-type values (#14)
+ - Use `auto` to deduce return values of operations inside various easings
+
- Version 3:
- Fix point duration calculation in multipoint tweening
- Implement `peek(float progress)` and `peek(uint32_t time)` to peek
at arbitrary points
- - Move examples to [tweeny-demos](github.com/mobius3/tweeny-demos) repository
+ - Move examples to [tweeny-demos](http://github.com/mobius3/tweeny-demos) repository
- Update README and docs
- Version 2:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8deab4b..e86ac80 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,6 @@
# This file is part of the Tweeny library.
#
-# Copyright (c) 2016 Leonardo G. Lucena de Freitas
+# Copyright (c) 2016-2021 Leonardo Guilherme Lucena de Freitas
# Copyright (c) 2016 Guilherme R. Costa
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -26,15 +26,13 @@
# instructions.
cmake_minimum_required(VERSION 3.0)
-project(Tweeny)
+cmake_policy(SET CMP0063 NEW)
+project(Tweeny LANGUAGES CXX VERSION 3.2.0)
# Setup variables and options
-option(TWEENY_BUILD_EXAMPLES "Build examples contained in examples/ folder. It might require additional dependencies." ON)
option(TWEENY_BUILD_DOCUMENTATION "Attempts to build the documentation. You'll need doxygen and graphviz installed" OFF)
-option(TWEENY_BUILD_EXTRAS "Attempts to build extra goodies on extras/ folder. It will require additional dependencies" ON)
-
-# Setup version
-include(cmake/SetupVersion.cmake)
+option(TWEENY_BUILD_SINGLE_HEADER "Joins together all header files in a single one. Needs Python 3.6 and quom installed" OFF)
+option(TWEENY_BUILD_SANDBOX "Adds a 'sandbox' target that links to tweeny. Useful when exploring tweeny" OFF)
# The library target
add_library(tweeny INTERFACE)
@@ -62,15 +60,13 @@ target_include_directories(tweeny INTERFACE
)
# Set up install
+include(GNUInstallDirs)
install(TARGETS tweeny EXPORT TweenyTargets)
-install(DIRECTORY include/ DESTINATION include/tweeny)
+install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tweeny)
# Set up export and config
include(cmake/SetupExports.cmake)
-# Set up cpack
-include(cmake/SetupCPack.cmake)
-
if (TWEENY_BUILD_DOCUMENTATION)
add_subdirectory(doc)
endif()
@@ -89,4 +85,13 @@ add_library(tweeny-dummy
include/easingresolve.h
include/int2type.h
include/dispatcher.h)
-set_target_properties(tweeny-dummy PROPERTIES LINKER_LANGUAGE CXX EXCLUDE_FROM_ALL TRUE)
\ No newline at end of file
+set_target_properties(tweeny-dummy PROPERTIES LINKER_LANGUAGE CXX EXCLUDE_FROM_ALL TRUE)
+
+if (TWEENY_BUILD_SINGLE_HEADER)
+ include(cmake/GenerateSingleHeader.cmake)
+endif()
+
+if (TWEENY_BUILD_SANDBOX)
+ add_executable(sandbox src/sandbox.cc)
+ target_link_libraries(sandbox tweeny)
+endif()
diff --git a/LICENSE b/LICENSE
index 018ac72..669b063 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,7 @@
The MIT License (MIT)
-Copyright (c) 2016 Leonardo Guilherme de Freitas
+Copyright (c) 2016-2021 Leonardo Guilherme Lucena de Freitas
+Copyright (c) 2016 Guilherme R. Costa
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 77e216a..2ace2f4 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,7 @@
# Tweeny
+<a href="https://repology.org/project/tweeny/versions">
+ <img src="https://repology.org/badge/vertical-allrepos/tweeny.svg" alt="Packaging status" align="right" style="padding-left: 20px">
+</a>
Tweeny is an inbetweening library designed for the creation of complex animations for games and other beautiful interactive software. It leverages features of modern C++ to empower developers with an intuitive API for declaring tweenings of any type of value, as long as they support arithmetic operations.
@@ -48,6 +51,10 @@ You just need to adjust your include path to point to the `include/` folder afte
Tweeny itself is a header only library. You can copy the `include/` folder into your project folder and then include from it: `#include "tweeny/tweeny.h"`
+**Copying the `tweeny-<version>.h` header**
+
+Since version 3.1.1 tweeny releases include a single-header file with all the necessary code glued together. Simply drop it on your project and/or adjust the include path and then `#include "tweeny-3.1.1.h"`.
+
**CMake subproject**
This is useful if you are using CMake already. Copy the whole tweeny project and include it in a top-level `CMakeLists.txt` file and then use `target_link_libraries` to add it to your target:
diff --git a/cmake/GenerateSingleHeader.cmake b/cmake/GenerateSingleHeader.cmake
new file mode 100644
index 0000000..08ff5e1
--- /dev/null
+++ b/cmake/GenerateSingleHeader.cmake
@@ -0,0 +1,22 @@
+# This cmake script is used to generate a single header file with all of tweeny
+find_package(Python 3.6 QUIET)
+
+if (NOT PYTHON_FOUND)
+ message(STATUS "Python 3.6 not found. Single-header include file will NOT be created")
+ return()
+endif()
+
+find_program(QUOM_EXECUTABLE NAMES quom)
+if (QUOM_EXECUTABLE-NOTFOUND)
+ message(STATUS "quom program not found. Install it with pip or easy_install")
+ return()
+endif()
+
+file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/single-header)
+
+add_custom_target(single-header
+ COMMAND
+ ${QUOM_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/include/tweeny.h ${CMAKE_CURRENT_BINARY_DIR}/single-header/tweeny-${Tweeny_VERSION}.h
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ COMMENT "Generating single header file"
+)
\ No newline at end of file
diff --git a/cmake/SetupCPack.cmake b/cmake/SetupCPack.cmake
deleted file mode 100644
index d5e8e7d..0000000
--- a/cmake/SetupCPack.cmake
+++ /dev/null
@@ -1,48 +0,0 @@
-# This file is part of the Tweeny library.
-#
-# Copyright (c) 2016 Leonardo G. Lucena de Freitas
-# Copyright (c) 2016 Guilherme R. Costa
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy of
-# this software and associated documentation files (the "Software"), to deal in
-# the Software without restriction, including without limitation the rights to
-# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-# the Software, and to permit persons to whom the Software is furnished to do so,
-# subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-# This file setups CPack to generate packages for Tweeny
-
-# Setup CPack variables
-set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Tweeny - a modern C++ tweening library.")
-set(CPACK_PACKAGE_VERSION_MAJOR "${TWEENY_VERSION_MAJOR}")
-set(CPACK_PACKAGE_VERSION_MINOR "${TWEENY_VERSION_MINOR}")
-set(CPACK_PACKAGE_VERSION_PATCH "${TWEENY_VERSION_PATCH}")
-set(CPACK_PACKAGE_CONTACT "leonardo.guilherme@gmail.com")
-set(CPACK_MONOLITHIC_INSTALL TRUE)
-set(CPACK_GENERATOR ZIP)
-
-# On Windows, also generate a NSIS package
-if (WIN32)
- list(APPEND CPACK_GENERATOR NSIS)
-endif()
-
-# On Unix-not-apple, generate tgz, deb and rpm packages
-if (UNIX AND NOT APPLE)
- list(APPEND CPACK_GENERATOR TGZ)
- list(APPEND CPACK_GENERATOR DEB)
- list(APPEND CPACK_GENERATOR RPM)
-endif()
-
-# This will enable the `make package` target.
-include(CPack)
-
diff --git a/cmake/SetupExports.cmake b/cmake/SetupExports.cmake
index c314471..692cc93 100644
--- a/cmake/SetupExports.cmake
+++ b/cmake/SetupExports.cmake
@@ -1,6 +1,6 @@
# This file is part of the Tweeny library.
#
-# Copyright (c) 2016 Leonardo G. Lucena de Freitas
+# Copyright (c) 2016-2021 Leonardo Guilherme Lucena de Freitas
# Copyright (c) 2016 Guilherme R. Costa
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -24,14 +24,15 @@
# when installed.
include(CMakePackageConfigHelpers)
+include(GNUInstallDirs)
# Setup install of exported targets
-install(EXPORT TweenyTargets DESTINATION lib/cmake/Tweeny)
+install(EXPORT TweenyTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Tweeny)
# Macro to write config
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/TweenyConfigVersion.cmake"
- VERSION ${TWEENY_VERSION}
+ VERSION ${Tweeny_VERSION}
COMPATIBILITY AnyNewerVersion
)
@@ -41,5 +42,5 @@ install(
cmake/TweenyConfig.cmake
"${CMAKE_CURRENT_BINARY_DIR}/TweenyConfigVersion.cmake"
DESTINATION
- lib/cmake/Tweeny
+ ${CMAKE_INSTALL_LIBDIR}/cmake/Tweeny
)
diff --git a/cmake/SetupVersion.cmake b/cmake/SetupVersion.cmake
deleted file mode 100644
index ef377d5..0000000
--- a/cmake/SetupVersion.cmake
+++ /dev/null
@@ -1,26 +0,0 @@
-# This file is part of the Tweeny library.
-#
-# Copyright (c) 2016 Leonardo G. Lucena de Freitas
-# Copyright (c) 2016 Guilherme R. Costa
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy of
-# this software and associated documentation files (the "Software"), to deal in
-# the Software without restriction, including without limitation the rights to
-# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-# the Software, and to permit persons to whom the Software is furnished to do so,
-# subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-set(TWEENY_VERSION 3)
-set(TWEENY_VERSION_MAJOR 3)
-set(TWEENY_VERSION_MINOR 0)
-set(TWEENY_VERSION_PATCH 0)
\ No newline at end of file
diff --git a/cmake/TweenyConfig.cmake b/cmake/TweenyConfig.cmake
index 5796d82..de985ab 100644
--- a/cmake/TweenyConfig.cmake
+++ b/cmake/TweenyConfig.cmake
@@ -1,6 +1,6 @@
# This file is part of the Tweeny library.
#
-# Copyright (c) 2016 Leonardo G. Lucena de Freitas
+# Copyright (c) 2016-2021 Leonardo Guilherme Lucena de Freitas
# Copyright (c) 2016 Guilherme R. Costa
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
diff --git a/debian/changelog b/debian/changelog
index 821e986..8ac32d2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+tweeny (3.2.0+git20210919.1.bfec586-1) UNRELEASED; urgency=low
+
+ * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk> Sat, 22 Oct 2022 21:30:19 -0000
+
tweeny (3-1) unstable; urgency=medium
* New upstream release.
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index 32d3bf8..68b7b74 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -22,29 +22,20 @@
# This cmake file creates and builds doxygen documentation. It also sets it in the install list.
-find_package(Doxygen)
-if (TWEENY_BUILD_DOCUMENTATION)
- set(DOC_ADD_TO_ALL ALL)
-else()
- set(DOC_ADD_TO_ALL "")
-endif()
+find_package(Doxygen REQUIRED)
-if(DOXYGEN_FOUND)
- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
- file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../README.md DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
- file(COPY
- ${CMAKE_CURRENT_SOURCE_DIR}/DoxygenLayout.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/MANUAL.dox
- DESTINATION
- ${CMAKE_CURRENT_BINARY_DIR}
- )
- add_custom_target(doc ${DOC_ADD_TO_ALL}
- ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- COMMENT "Generating API documentation with Doxygen" VERBATIM)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
+file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../README.md DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+file(COPY
+ ${CMAKE_CURRENT_SOURCE_DIR}/DoxygenLayout.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/MANUAL.dox
+ DESTINATION
+ ${CMAKE_CURRENT_BINARY_DIR}
+)
+add_custom_target(doc ALL
+ ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ COMMENT "Generating API documentation with Doxygen" VERBATIM)
- if (TWEENY_BUILD_DOCUMENTATION)
- install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/doc/Tweeny)
- endif()
-
-endif(DOXYGEN_FOUND)
+include(GNUInstallDirs)
+install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION ${CMAKE_INSTALL_DOCDIR})
diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in
index 2c58707..d6cea5d 100644
--- a/doc/Doxyfile.in
+++ b/doc/Doxyfile.in
@@ -38,7 +38,7 @@ PROJECT_NAME = "Tweeny"
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = @TWEENY_VERSION@
+PROJECT_NUMBER = @Tweeny_VERSION@
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
@@ -399,7 +399,7 @@ TYPEDEF_HIDES_STRUCT = NO
# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range
# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536
# symbols. At the end of a run doxygen will report the cache usage and suggest
-# the optimal cache size from a speed currentPoint of view.
+# the optimal cache size from a speed point of view.
# Minimum value: 0, maximum value: 9, default value: 0.
LOOKUP_CACHE_SIZE = 0
@@ -965,7 +965,7 @@ REFERENCES_LINK_SOURCE = YES
SOURCE_TOOLTIPS = YES
# If the USE_HTAGS tag is set to YES then the references to source code will
-# currentPoint to the HTML generated by the htags(1) tool instead of doxygen built-in
+# point to the HTML generated by the htags(1) tool instead of doxygen built-in
# source browser. The htags tool is part of GNU's global source tagging system
# (see http://www.gnu.org/software/global/global.html). You will need version
# 4.8.6 or higher.
@@ -980,7 +980,7 @@ SOURCE_TOOLTIPS = YES
# tools must be available from the command line (i.e. in the search path).
#
# The result: instead of the source browser generated by doxygen, the links to
-# source code will now currentPoint to the output of htags.
+# source code will now point to the output of htags.
# The default value is: NO.
# This tag requires that the tag SOURCE_BROWSER is set to YES.
@@ -1546,7 +1546,7 @@ SERVER_BASED_SEARCH = NO
EXTERNAL_SEARCH = NO
-# The SEARCHENGINE_URL should currentPoint to a search engine hosted by a web server
+# The SEARCHENGINE_URL should point to a search engine hosted by a web server
# which will return the search results when EXTERNAL_SEARCH is enabled.
#
# Doxygen ships with an example indexer (doxyindexer) and search engine
diff --git a/include/dispatcher.h b/include/dispatcher.h
index 51c55d3..17f9a75 100644
--- a/include/dispatcher.h
+++ b/include/dispatcher.h
@@ -1,7 +1,7 @@
/*
This file is part of the Tweeny library.
- Copyright (c) 2016-2018 Leonardo G. Lucena de Freitas
+ Copyright (c) 2016-2021 Leonardo Guilherme Lucena de Freitas
Copyright (c) 2016 Guilherme R. Costa
Permission is hereby granted, free of charge, to any person obtaining a copy of
diff --git a/include/easing.h b/include/easing.h
index b5f8260..81ea227 100644
--- a/include/easing.h
+++ b/include/easing.h
@@ -1,7 +1,7 @@
/*
This file is part of the Tweeny library.
- Copyright (c) 2016-2018 Leonardo G. Lucena de Freitas
+ Copyright (c) 2016-2021 Leonardo Guilherme Lucena de Freitas
Copyright (c) 2016 Guilherme R. Costa
Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -46,6 +46,16 @@
* @sa tweeny::easing
* @{
*//**
+ * @defgroup stepped Stepped
+ * @{
+ * @brief The value does not change. No interpolation is used.
+ * @}
+ *//**
+ * @defgroup default Default
+ * @{
+ * @brief A default mode for arithmetic values it will change in constant speed, for non-arithmetic value will be constant.
+ * @}
+ *//**
* @defgroup linear Linear
* @{
* @brief The most boring ever easing function. It has no acceleration and change values in constant speed.
@@ -109,7 +119,7 @@ namespace tweeny {
* @brief The easing class holds all the bundled easings.
*
* You should pass the easing function to the @p tweeny::tween::via method, to set the easing function that will
- * be used to interpolate values in a tween currentPoint.
+ * be used to interpolate values in a tween point.
*
* **Example**:
*
@@ -119,6 +129,96 @@ namespace tweeny {
*/
class easing {
public:
+ /**
+ * @brief Enumerates all easings to aid in runtime when adding easins to a tween using tween::via
+ *
+ * The aim of this enum is to help in situations where the easing doesn't come straight from the C++
+ * code but rather from a configuration file or some sort of external paramenter.
+ */
+ enum class enumerated {
+ def,
+ linear,
+ stepped,
+ quadraticIn,
+ quadraticOut,
+ quadraticInOut,
+ cubicIn,
+ cubicOut,
+ cubicInOut,
+ quarticIn,
+ quarticOut,
+ quarticInOut,
+ quinticIn,
+ quinticOut,
+ quinticInOut,
+ sinusoidalIn,
+ sinusoidalOut,
+ sinusoidalInOut,
+ exponentialIn,
+ exponentialOut,
+ exponentialInOut,
+ circularIn,
+ circularOut,
+ circularInOut,
+ bounceIn,
+ bounceOut,
+ bounceInOut,
+ elasticIn,
+ elasticOut,
+ elasticInOut,
+ backIn,
+ backOut,
+ backInOut
+ };
+
+ /**
+ * @ingroup stepped
+ * @brief Value is constant.
+ */
+ static constexpr struct steppedEasing {
+ template<typename T>
+ static T run(float position, T start, T end) {
+ return start;
+ }
+ } stepped = steppedEasing{};
+
+ /**
+ * @ingroup default
+ * @brief Values change with constant speed for arithmetic type only. The non-arithmetic it will be constant.
+ */
+ static constexpr struct defaultEasing {
+ template<class...> struct voidify { using type = void; };
+ template<class... Ts> using void_t = typename voidify<Ts...>::type;
+
+ template<class T, class = void>
+ struct supports_arithmetic_operations : std::false_type {};
+
+ template<class T>
+ struct supports_arithmetic_operations<T, void_t<
+ decltype(std::declval<T>() + std::declval<T>()),
+ decltype(std::declval<T>() - std::declval<T>()),
+ decltype(std::declval<T>() * std::declval<T>()),
+ decltype(std::declval<T>() * std::declval<float>()),
+ decltype(std::declval<float>() * std::declval<T>())
+ >> : std::true_type{};
+
+
+ template<typename T>
+ static typename std::enable_if<std::is_integral<T>::value, T>::type run(float position, T start, T end) {
+ return static_cast<T>(roundf((end - start) * position + start));
+ }
+
+ template<typename T>
+ static typename std::enable_if<supports_arithmetic_operations<T>::value && !std::is_integral<T>::value, T>::type run(float position, T start, T end) {
+ return static_cast<T>((end - start) * position + start);
+ }
+
+ template<typename T>
+ static typename std::enable_if<!supports_arithmetic_operations<T>::value, T>::type run(float position, T start, T end) {
+ return start;
+ }
+ } def = defaultEasing{};
+
/**
* @ingroup linear
* @brief Values change with constant speed.
@@ -465,7 +565,7 @@ namespace tweeny {
if (position <= 0.00001f) return start;
if (position >= 0.999f) return end;
float p = .3f;
- float a = end - start;
+ auto a = end - start;
float s = p / 4;
float postFix =
a * powf(2, 10 * (position -= 1)); // this is a fix, again, with post-increment operators
@@ -483,7 +583,7 @@ namespace tweeny {
if (position <= 0.00001f) return start;
if (position >= 0.999f) return end;
float p = .3f;
- float a = end - start;
+ auto a = end - start;
float s = p / 4;
return static_cast<T>(a * powf(2, -10 * position) * sinf((position - s) * (2 * static_cast<float>(M_PI)) / p) + end);
}
@@ -500,7 +600,7 @@ namespace tweeny {
if (position >= 0.999f) return end;
position *= 2;
float p = (.3f * 1.5f);
- float a = end - start;
+ auto a = end - start;
float s = p / 4;
float postFix;
@@ -548,8 +648,8 @@ namespace tweeny {
static T run(float position, T start, T end) {
float s = 1.70158f;
float t = position;
- T b = start;
- T c = end - start;
+ auto b = start;
+ auto c = end - start;
float d = 1;
s *= (1.525f);
if ((t /= d / 2) < 1) return static_cast<T>(c / 2 * (t * t * (((s) + 1) * t - s)) + b);
diff --git a/include/easingresolve.h b/include/easingresolve.h
index fe6a19c..f7d266e 100644
--- a/include/easingresolve.h
+++ b/include/easingresolve.h
@@ -1,7 +1,7 @@
/*
This file is part of the Tweeny library.
- Copyright (c) 2016-2018 Leonardo G. Lucena de Freitas
+ Copyright (c) 2016-2021 Leonardo Guilherme Lucena de Freitas
Copyright (c) 2016 Guilherme R. Costa
Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -54,6 +54,16 @@ namespace tweeny {
}
};
+ template<int I, typename TypeTuple, typename FunctionTuple, typename... Fs>
+ struct easingresolve<I, TypeTuple, FunctionTuple, easing::steppedEasing, Fs...> {
+ typedef typename std::tuple_element<I, TypeTuple>::type ArgType;
+
+ static void impl(FunctionTuple &b, easing::steppedEasing, Fs... fs) {
+ get<I>(b) = easing::stepped.run<ArgType>;
+ easingresolve<I + 1, TypeTuple, FunctionTuple, Fs...>::impl(b, fs...);
+ }
+ };
+
template<int I, typename TypeTuple, typename FunctionTuple, typename... Fs>
struct easingresolve<I, TypeTuple, FunctionTuple, easing::linearEasing, Fs...> {
typedef typename std::tuple_element<I, TypeTuple>::type ArgType;
@@ -63,6 +73,15 @@ namespace tweeny {
easingresolve<I + 1, TypeTuple, FunctionTuple, Fs...>::impl(b, fs...);
}
};
+ template<int I, typename TypeTuple, typename FunctionTuple, typename... Fs>
+ struct easingresolve<I, TypeTuple, FunctionTuple, easing::defaultEasing, Fs...> {
+ typedef typename std::tuple_element<I, TypeTuple>::type ArgType;
+
+ static void impl(FunctionTuple &b, easing::defaultEasing, Fs... fs) {
+ get<I>(b) = easing::def.run<ArgType>;
+ easingresolve<I + 1, TypeTuple, FunctionTuple, Fs...>::impl(b, fs...);
+ }
+ };
#define DECLARE_EASING_RESOLVE(__EASING_TYPE__) \
template <int I, typename TypeTuple, typename FunctionTuple, typename... Fs> \
diff --git a/include/int2type.h b/include/int2type.h
index 6deb514..a0d8f17 100644
--- a/include/int2type.h
+++ b/include/int2type.h
@@ -1,7 +1,7 @@
/*
This file is part of the Tweeny library.
- Copyright (c) 2016-2018 Leonardo G. Lucena de Freitas
+ Copyright (c) 2016-2021 Leonardo Guilherme Lucena de Freitas
Copyright (c) 2016 Guilherme R. Costa
Permission is hereby granted, free of charge, to any person obtaining a copy of
diff --git a/include/tween.h b/include/tween.h
index 38803f1..ad64dfd 100644
--- a/include/tween.h
+++ b/include/tween.h
@@ -1,7 +1,7 @@
/*
This file is part of the Tweeny library.
- Copyright (c) 2016-2018 Leonardo G. Lucena de Freitas
+ Copyright (c) 2016-2021 Leonardo Guilherme Lucena de Freitas
Copyright (c) 2016 Guilherme R. Costa
Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -33,6 +33,7 @@
#include <tuple>
#include <vector>
#include <functional>
+#include <string>
#include "tweentraits.h"
#include "tweenpoint.h"
@@ -48,7 +49,7 @@ namespace tweeny {
class tween {
public:
/**
- * @brief Instantiates a tween from a starting currentPoint.
+ * @brief Instantiates a tween from a starting point.
*
* This is a static factory helper function to be used by @p tweeny::from. You should not use this directly.
* @p t The first value in the point
@@ -66,10 +67,10 @@ namespace tweeny {
tween();
/**
- * @brief Adds a new currentPoint in this tweening.
+ * @brief Adds a new point in this tweening.
*
- * This will add a new tweening currentPoint with the specified values. Next calls to @p via and @p during
- * will refer to this currentPoint.
+ * This will add a new tweening point with the specified values. Next calls to @p via and @p during
+ * will refer to this point.
*
* **Example**
*
@@ -83,12 +84,12 @@ namespace tweeny {
tween<T, Ts...> & to(T t, Ts... vs);
/**
- * @brief Specifies the easing function for the last added currentPoint.
+ * @brief Specifies the easing function for the last added point.
*
- * This will specify the easing between the last tween currentPoint added by @p to and its previous step. You can
+ * This will specify the easing between the last tween point added by @p to and its previous step. You can
* use any callable object. Additionally, you can use the easing objects specified in the class @p easing.
*
- * If it is a multi-value currentPoint, you can either specify a single easing function that will be used for
+ * If it is a multi-value point, you can either specify a single easing function that will be used for
* every value or you can specify an easing function for each value. You can mix and match callable objects,
* lambdas and bundled easing objects.
*
@@ -108,14 +109,69 @@ namespace tweeny {
*/
template<typename... Fs> tween<T, Ts...> & via(Fs... fs);
+
+ /**
+ * @brief Specifies the easing function for the last added point, accepting an enumeration.
+ *
+ * This will specify the easing between the last tween point added by @p to and its previous step. You can
+ * use a value from the @p tweeny::easing::enumerated enum. You can then have an enumeration of your own
+ * poiting to this enumerated enums, or use it directly. You can mix-and-match enumerated easings, functions
+ * and easing names.
+ *
+ * **Example**:
+ *
+ * @code
+ * auto tween1 = tweeny::from(0).to(100).via(tweeny::easing::enumerated::linear);
+ * auto tween2 = tweeny::from(0.0f, 100.0f).to(100.0f, 0.0f).via(tweeny::easing::linear, "backOut");
+ *
+ * @param fs The functions
+ * @returns *this
+ * @see tweeny::easing
+ */
+ template<typename... Fs> tween<T, Ts...> & via(easing::enumerated enumerated, Fs... fs);
+
+ /**
+ * @brief Specifies the easing function for the last added point, accepting an easing name as a `std::string` value.
+ *
+ * This will specify the easing between the last tween point added by @p to and its previous step.
+ * You can mix-and-match enumerated easings, functions and easing names.
+ *
+ * **Example**:
+ *
+ * @code
+ * auto tween = tweeny::from(0.0f, 100.0f).to(100.0f, 0.0f).via(tweeny::easing::linear, "backOut");
+ *
+ * @param fs The functions
+ * @returns *this
+ * @see tweeny::easing
+ */
+ template<typename... Fs> tween<T, Ts...> & via(const std::string & easing, Fs... fs);
+
+ /**
+ * @brief Specifies the easing function for the last added point, accepting an easing name as a `const char *` value.
+ *
+ * This will specify the easing between the last tween point added by @p to and its previous step.
+ * You can mix-and-match enumerated easings, functions and easing names.
+ *
+ * **Example**:
+ *
+ * @code
+ * auto tween = tweeny::from(0.0f, 100.0f).to(100.0f, 0.0f).via(tweeny::easing::linear, "backOut");
+ *
+ * @param fs The functions
+ * @returns *this
+ * @see tweeny::easing
+ */
+ template<typename... Fs> tween<T, Ts...> & via(const char * easing, Fs... fs);
+
/**
- * @brief Specifies the easing function for a specific currentPoint.
+ * @brief Specifies the easing function for a specific point.
*
* Points starts at index 0. The index 0 refers to the first @p to call.
- * Using this function without adding a currentPoint with @p to leads to undefined
+ * Using this function without adding a point with @p to leads to undefined
* behaviour.
*
- * @param index The tween currentPoint index
+ * @param index The tween point index
* @param fs The functions
* @returns *this
* @see tweeny::easing
@@ -123,7 +179,7 @@ namespace tweeny {
template<typename... Fs> tween<T, Ts...> & via(int index, Fs... fs);
/**
- * @brief Specifies the duration, typically in milliseconds, for the tweening of values in last currentPoint.
+ * @brief Specifies the duration, typically in milliseconds, for the tweening of values in last point.
*
* You can either specify a single duration for all values or give every value its own duration. Value types
* must be convertible to the uint16_t type.
@@ -131,8 +187,8 @@ namespace tweeny {
* **Example**:
*
* @code
- * // Specify that the first currentPoint will be reached in 100 milliseconds and the first value in the second
- * // currentPoint in 100, whereas the second value will be reached in 500.
+ * // Specify that the first point will be reached in 100 milliseconds and the first value in the second
+ * // point in 100, whereas the second value will be reached in 500.
* auto tween = tweeny::from(0, 0).to(100, 200).during(100).to(200, 300).during(100, 500);
* @endcode
*
@@ -197,7 +253,7 @@ namespace tweeny {
const typename detail::tweentraits<T, Ts...>::valuesType & step(float dp, bool suppressCallbacks = false);
/**
- * @brief Seeks to a specified currentPoint in time based on the currentProgress.
+ * @brief Seeks to a specified point in time based on the currentProgress.
*
* This function sets the current animation time and currentProgress. Callbacks set by @p call will be triggered.
*
@@ -208,7 +264,7 @@ namespace tweeny {
const typename detail::tweentraits<T, Ts...>::valuesType & seek(float p, bool suppressCallbacks = false);
/**
- * @brief Seeks to a specified currentPoint in time.
+ * @brief Seeks to a specified point in time.
*
* This function sets the current animation time and currentProgress. Callbacks set by @p call will be triggered.
*
@@ -220,7 +276,7 @@ namespace tweeny {
const typename detail::tweentraits<T, Ts...>::valuesType & seek(int32_t d, bool suppressCallbacks = false);
/**
- * @brief Seeks to a specified currentPoint in time.
+ * @brief Seeks to a specified point in time.
*
* This function sets the current animation time and currentProgress. Callbacks set by @p call will be triggered.
*
@@ -484,16 +540,16 @@ namespace tweeny {
int direction() const;
/**
- * @brief Jumps to a specific tween currentPoint
+ * @brief Jumps to a specific tween point
*
* This will seek the tween to a percentage matching the beginning of that step.
*
- * @param point The currentPoint to seek to. 0 means the currentPoint passed in tweeny::from
+ * @param point The point to seek to. 0 means the point passed in tweeny::from
* @param suppressCallbacks (optional) set to true to suppress seek() callbacks
* @returns current values
* @sa seek
*/
- const typename detail::tweentraits<T, Ts...>::valuesType & jump(int32_t point, bool suppressCallbacks = false);
+ const typename detail::tweentraits<T, Ts...>::valuesType & jump(size_t point, bool suppressCallbacks = false);
/**
* @brief Returns the current tween point
@@ -507,8 +563,8 @@ namespace tweeny {
private /* member variables */:
uint32_t total = 0; // total runtime
- uint16_t currentPoint = 0; // current currentPoint
- float currentProgress = 0; // current currentProgress
+ uint16_t currentPoint = 0; // current point
+ float currentProgress = 0; // current progress
std::vector<detail::tweenpoint<T, Ts...>> points;
typename traits::valuesType current;
std::vector<typename traits::callbackType> onStepCallbacks;
@@ -545,6 +601,9 @@ namespace tweeny {
tween<T> & to(T t); ///< @sa tween::to
template<typename... Fs> tween<T> & via(Fs... fs); ///< @sa tween::via
template<typename... Fs> tween<T> & via(int index, Fs... fs); ///< @sa tween::via
+ template<typename... Fs> tween<T> & via(tweeny::easing::enumerated enumerated, Fs... fs); ///< @sa tween::via
+ template<typename... Fs> tween<T> & via(const std::string & easing, Fs... fs); ///< @sa tween::via
+ template<typename... Fs> tween<T> & via(const char * easing, Fs... fs); ///< @sa tween::via
template<typename... Ds> tween<T> & during(Ds... ds); ///< @sa tween::during
const T & step(int32_t dt, bool suppressCallbacks = false); ///< @sa tween::step(int32_t dt, bool suppressCallbacks)
const T & step(uint32_t dt, bool suppressCallbacks = false); ///< @sa tween::step(uint32_t dt, bool suppressCallbacks)
@@ -566,7 +625,7 @@ namespace tweeny {
tween<T> & forward(); ///< @sa tween::forward
tween<T> & backward(); ///< @sa tween::backward
int direction() const; ///< @sa tween::direction
- const T & jump(int32_t point, bool suppressCallbacks = false); ///< @sa tween::jump
+ const T & jump(size_t point, bool suppressCallbacks = false); ///< @sa tween::jump
uint16_t point() const; ///< @sa tween::point
private /* member types */:
@@ -574,8 +633,8 @@ namespace tweeny {
private /* member variables */:
uint32_t total = 0; // total runtime
- uint16_t currentPoint = 0; // current currentPoint
- float currentProgress = 0; // current currentProgress
+ uint16_t currentPoint = 0; // current point
+ float currentProgress = 0; // current progress
std::vector<detail::tweenpoint<T>> points;
T current;
std::vector<typename traits::callbackType> onStepCallbacks;
diff --git a/include/tween.tcc b/include/tween.tcc
index a4b6c6b..dd0e77f 100644
--- a/include/tween.tcc
+++ b/include/tween.tcc
@@ -1,7 +1,7 @@
/*
This file is part of the Tweeny library.
- Copyright (c) 2016-2018 Leonardo G. Lucena de Freitas
+ Copyright (c) 2016-2021 Leonardo Guilherme Lucena de Freitas
Copyright (c) 2016 Guilherme R. Costa
Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -66,6 +66,91 @@ namespace tweeny {
return *this;
}
+ template<typename T, typename... Ts>
+ template<typename... Fs>
+ tween<T, Ts...> & tween<T, Ts...>::via(easing::enumerated enumerated, Fs... vs) {
+ switch (enumerated) {
+ case easing::enumerated::def: return via(easing::def, vs...);
+ case easing::enumerated::linear: return via(easing::linear, vs...);
+ case easing::enumerated::stepped: return via(easing::stepped, vs...);
+ case easing::enumerated::quadraticIn: return via(easing::quadraticIn, vs...);
+ case easing::enumerated::quadraticOut: return via(easing::quadraticOut, vs...);
+ case easing::enumerated::quadraticInOut: return via(easing::quadraticInOut, vs...);
+ case easing::enumerated::cubicIn: return via(easing::cubicIn, vs...);
+ case easing::enumerated::cubicOut: return via(easing::cubicOut, vs...);
+ case easing::enumerated::cubicInOut: return via(easing::cubicInOut, vs...);
+ case easing::enumerated::quarticIn: return via(easing::quarticIn, vs...);
+ case easing::enumerated::quarticOut: return via(easing::quarticOut, vs...);
+ case easing::enumerated::quarticInOut: return via(easing::quarticInOut, vs...);
+ case easing::enumerated::quinticIn: return via(easing::quinticIn, vs...);
+ case easing::enumerated::quinticOut: return via(easing::quinticOut, vs...);
+ case easing::enumerated::quinticInOut: return via(easing::quinticInOut, vs...);
+ case easing::enumerated::sinusoidalIn: return via(easing::sinusoidalIn, vs...);
+ case easing::enumerated::sinusoidalOut: return via(easing::sinusoidalOut, vs...);
+ case easing::enumerated::sinusoidalInOut: return via(easing::sinusoidalInOut, vs...);
+ case easing::enumerated::exponentialIn: return via(easing::exponentialIn, vs...);
+ case easing::enumerated::exponentialOut: return via(easing::exponentialOut, vs...);
+ case easing::enumerated::exponentialInOut: return via(easing::exponentialInOut, vs...);
+ case easing::enumerated::circularIn: return via(easing::circularIn, vs...);
+ case easing::enumerated::circularOut: return via(easing::circularOut, vs...);
+ case easing::enumerated::circularInOut: return via(easing::circularInOut, vs...);
+ case easing::enumerated::bounceIn: return via(easing::bounceIn, vs...);
+ case easing::enumerated::bounceOut: return via(easing::bounceOut, vs...);
+ case easing::enumerated::bounceInOut: return via(easing::bounceInOut, vs...);
+ case easing::enumerated::elasticIn: return via(easing::elasticIn, vs...);
+ case easing::enumerated::elasticOut: return via(easing::elasticOut, vs...);
+ case easing::enumerated::elasticInOut: return via(easing::elasticInOut, vs...);
+ case easing::enumerated::backIn: return via(easing::backIn, vs...);
+ case easing::enumerated::backOut: return via(easing::backOut, vs...);
+ case easing::enumerated::backInOut: return via(easing::backInOut, vs...);
+ default: return via(easing::def, vs...);
+ }
+ }
+
+ template<typename T, typename... Ts>
+ template<typename... Fs>
+ tween<T, Ts...> & tween<T, Ts...>::via(const std::string & easing, Fs... vs) {
+ if (easing == "stepped") return via(easing::stepped, vs...);
+ if (easing == "linear") return via(easing::linear, vs...);
+ if (easing == "quadraticIn") return via(easing::quadraticIn, vs...);
+ if (easing == "quadraticOut") return via(easing::quadraticOut, vs...);
+ if (easing == "quadraticInOut") return via(easing::quadraticInOut, vs...);
+ if (easing == "cubicIn") return via(easing::cubicIn, vs...);
+ if (easing == "cubicOut") return via(easing::cubicOut, vs...);
+ if (easing == "cubicInOut") return via(easing::cubicInOut, vs...);
+ if (easing == "quarticIn") return via(easing::quarticIn, vs...);
+ if (easing == "quarticOut") return via(easing::quarticOut, vs...);
+ if (easing == "quarticInOut") return via(easing::quarticInOut, vs...);
+ if (easing == "quinticIn") return via(easing::quinticIn, vs...);
+ if (easing == "quinticOut") return via(easing::quinticOut, vs...);
+ if (easing == "quinticInOut") return via(easing::quinticInOut, vs...);
+ if (easing == "sinusoidalIn") return via(easing::sinusoidalIn, vs...);
+ if (easing == "sinusoidalOut") return via(easing::sinusoidalOut, vs...);
+ if (easing == "sinusoidalInOut") return via(easing::sinusoidalInOut, vs...);
+ if (easing == "exponentialIn") return via(easing::exponentialIn, vs...);
+ if (easing == "exponentialOut") return via(easing::exponentialOut, vs...);
+ if (easing == "exponentialInOut") return via(easing::exponentialInOut, vs...);
+ if (easing == "circularIn") return via(easing::circularIn, vs...);
+ if (easing == "circularOut") return via(easing::circularOut, vs...);
+ if (easing == "circularInOut") return via(easing::circularInOut, vs...);
+ if (easing == "bounceIn") return via(easing::bounceIn, vs...);
+ if (easing == "bounceOut") return via(easing::bounceOut, vs...);
+ if (easing == "bounceInOut") return via(easing::bounceInOut, vs...);
+ if (easing == "elasticIn") return via(easing::elasticIn, vs...);
+ if (easing == "elasticOut") return via(easing::elasticOut, vs...);
+ if (easing == "elasticInOut") return via(easing::elasticInOut, vs...);
+ if (easing == "backIn") return via(easing::backIn, vs...);
+ if (easing == "backOut") return via(easing::backOut, vs...);
+ if (easing == "backInOut") return via(easing::backInOut, vs...);
+ return via(easing::def, vs...);
+ }
+
+ template<typename T, typename... Ts>
+ template<typename... Fs>
+ tween <T, Ts...> & tween<T, Ts...>::via(const char * easing, Fs... vs) {
+ return via(std::string(easing));
+ }
+
template<typename T, typename... Ts>
template<typename... Ds>
inline tween<T, Ts...> & tween<T, Ts...>::during(Ds... ds) {
@@ -80,7 +165,7 @@ namespace tweeny {
template<typename T, typename... Ts>
inline const typename detail::tweentraits<T, Ts...>::valuesType & tween<T, Ts...>::step(int32_t dt, bool suppress) {
- return step(static_cast<float>(dt * currentDirection)/static_cast<float>(total), suppress);
+ return step(static_cast<float>(dt)/static_cast<float>(total), suppress);
}
template<typename T, typename... Ts>
@@ -90,6 +175,7 @@ namespace tweeny {
template<typename T, typename... Ts>
inline const typename detail::tweentraits<T, Ts...>::valuesType & tween<T, Ts...>::step(float dp, bool suppress) {
+ dp *= currentDirection;
seek(currentProgress + dp, true);
if (!suppress) dispatch(onStepCallbacks);
return current;
@@ -118,8 +204,8 @@ namespace tweeny {
template<size_t I>
inline void tween<T, Ts...>::interpolate(float prog, unsigned point, typename traits::valuesType & values, detail::int2type<I>) const {
auto & p = points.at(point);
- uint32_t pointDuration = p.duration() - (p.stacked - (prog * static_cast<float>(total)));
- float pointTotal = static_cast<float>(pointDuration) / static_cast<float>(p.duration());
+ auto pointDuration = uint32_t(p.duration() - (p.stacked - (prog * static_cast<float>(total))));
+ float pointTotal = static_cast<float>(pointDuration) / static_cast<float>(p.duration(I));
if (pointTotal > 1.0f) pointTotal = 1.0f;
auto easing = std::get<I>(p.easings);
std::get<I>(values) = easing(pointTotal, std::get<I>(p.values), std::get<I>(points.at(point+1).values));
@@ -129,8 +215,8 @@ namespace tweeny {
template<typename T, typename... Ts>
inline void tween<T, Ts...>::interpolate(float prog, unsigned point, typename traits::valuesType & values, detail::int2type<0>) const {
auto & p = points.at(point);
- uint32_t pointDuration = p.duration() - (p.stacked - (prog * static_cast<float>(total)));
- float pointTotal = static_cast<float>(pointDuration) / static_cast<float>(p.duration());
+ auto pointDuration = uint32_t(p.duration() - (p.stacked - (prog * static_cast<float>(total))));
+ float pointTotal = static_cast<float>(pointDuration) / static_cast<float>(p.duration(0));
if (pointTotal > 1.0f) pointTotal = 1.0f;
auto easing = std::get<0>(p.easings);
std::get<0>(values) = easing(pointTotal, std::get<0>(p.values), std::get<0>(points.at(point+1).values));
@@ -239,22 +325,23 @@ namespace tweeny {
}
template<typename T, typename... Ts>
- inline const typename detail::tweentraits<T, Ts...>::valuesType & tween<T, Ts...>::jump(int32_t p, bool suppress) {
- p = detail::clip(p, 0, points.size() -1);
- return seek(points.at(p).stacked, suppress);
+ inline const typename detail::tweentraits<T, Ts...>::valuesType & tween<T, Ts...>::jump(std::size_t p, bool suppress) {
+ p = detail::clip(p, static_cast<size_t>(0), points.size() -1);
+ return seek(static_cast<int32_t>(points.at(p).stacked), suppress);
}
template<typename T, typename... Ts> inline uint16_t tween<T, Ts...>::point() const {
return currentPoint;
- };
+ }
template<typename T, typename... Ts> inline uint16_t tween<T, Ts...>::pointAt(float progress) const {
+ progress = detail::clip(progress, 0.0f, 1.0f);
uint32_t t = static_cast<uint32_t>(progress * total);
uint16_t point = 0;
while (t > points.at(point).stacked) point++;
if (point > 0 && t <= points.at(point - 1u).stacked) point--;
return point;
- };
+ }
}
#endif //TWEENY_TWEEN_TCC
diff --git a/include/tweenone.tcc b/include/tweenone.tcc
index 9380f0d..c2a52ad 100644
--- a/include/tweenone.tcc
+++ b/include/tweenone.tcc
@@ -1,7 +1,7 @@
/*
This file is part of the Tweeny library.
- Copyright (c) 2016-2018 Leonardo G. Lucena de Freitas
+ Copyright (c) 2016-2021 Leonardo Guilherme Lucena de Freitas
Copyright (c) 2016 Guilherme R. Costa
Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -58,6 +58,91 @@ namespace tweeny {
return *this;
}
+ template<typename T>
+ template<typename... Fs>
+ tween <T> & tween<T>::via(easing::enumerated enumerated, Fs... vs) {
+ switch (enumerated) {
+ case easing::enumerated::def: return via(easing::def, vs...);
+ case easing::enumerated::linear: return via(easing::linear, vs...);
+ case easing::enumerated::stepped: return via(easing::stepped, vs...);
+ case easing::enumerated::quadraticIn: return via(easing::quadraticIn, vs...);
+ case easing::enumerated::quadraticOut: return via(easing::quadraticOut, vs...);
+ case easing::enumerated::quadraticInOut: return via(easing::quadraticInOut, vs...);
+ case easing::enumerated::cubicIn: return via(easing::cubicIn, vs...);
+ case easing::enumerated::cubicOut: return via(easing::cubicOut, vs...);
+ case easing::enumerated::cubicInOut: return via(easing::cubicInOut, vs...);
+ case easing::enumerated::quarticIn: return via(easing::quarticIn, vs...);
+ case easing::enumerated::quarticOut: return via(easing::quarticOut, vs...);
+ case easing::enumerated::quarticInOut: return via(easing::quarticInOut, vs...);
+ case easing::enumerated::quinticIn: return via(easing::quinticIn, vs...);
+ case easing::enumerated::quinticOut: return via(easing::quinticOut, vs...);
+ case easing::enumerated::quinticInOut: return via(easing::quinticInOut, vs...);
+ case easing::enumerated::sinusoidalIn: return via(easing::sinusoidalIn, vs...);
+ case easing::enumerated::sinusoidalOut: return via(easing::sinusoidalOut, vs...);
+ case easing::enumerated::sinusoidalInOut: return via(easing::sinusoidalInOut, vs...);
+ case easing::enumerated::exponentialIn: return via(easing::exponentialIn, vs...);
+ case easing::enumerated::exponentialOut: return via(easing::exponentialOut, vs...);
+ case easing::enumerated::exponentialInOut: return via(easing::exponentialInOut, vs...);
+ case easing::enumerated::circularIn: return via(easing::circularIn, vs...);
+ case easing::enumerated::circularOut: return via(easing::circularOut, vs...);
+ case easing::enumerated::circularInOut: return via(easing::circularInOut, vs...);
+ case easing::enumerated::bounceIn: return via(easing::bounceIn, vs...);
+ case easing::enumerated::bounceOut: return via(easing::bounceOut, vs...);
+ case easing::enumerated::bounceInOut: return via(easing::bounceInOut, vs...);
+ case easing::enumerated::elasticIn: return via(easing::elasticIn, vs...);
+ case easing::enumerated::elasticOut: return via(easing::elasticOut, vs...);
+ case easing::enumerated::elasticInOut: return via(easing::elasticInOut, vs...);
+ case easing::enumerated::backIn: return via(easing::backIn, vs...);
+ case easing::enumerated::backOut: return via(easing::backOut, vs...);
+ case easing::enumerated::backInOut: return via(easing::backInOut, vs...);
+ default: return via(easing::def, vs...);
+ }
+ }
+
+ template<typename T>
+ template<typename... Fs>
+ tween <T> & tween<T>::via(const std::string & easing, Fs... vs) {
+ if (easing == "stepped") return via(easing::stepped, vs...);
+ if (easing == "linear") return via(easing::linear, vs...);
+ if (easing == "quadraticIn") return via(easing::quadraticIn, vs...);
+ if (easing == "quadraticOut") return via(easing::quadraticOut, vs...);
+ if (easing == "quadraticInOut") return via(easing::quadraticInOut, vs...);
+ if (easing == "cubicIn") return via(easing::cubicIn, vs...);
+ if (easing == "cubicOut") return via(easing::cubicOut, vs...);
+ if (easing == "cubicInOut") return via(easing::cubicInOut, vs...);
+ if (easing == "quarticIn") return via(easing::quarticIn, vs...);
+ if (easing == "quarticOut") return via(easing::quarticOut, vs...);
+ if (easing == "quarticInOut") return via(easing::quarticInOut, vs...);
+ if (easing == "quinticIn") return via(easing::quinticIn, vs...);
+ if (easing == "quinticOut") return via(easing::quinticOut, vs...);
+ if (easing == "quinticInOut") return via(easing::quinticInOut, vs...);
+ if (easing == "sinusoidalIn") return via(easing::sinusoidalIn, vs...);
+ if (easing == "sinusoidalOut") return via(easing::sinusoidalOut, vs...);
+ if (easing == "sinusoidalInOut") return via(easing::sinusoidalInOut, vs...);
+ if (easing == "exponentialIn") return via(easing::exponentialIn, vs...);
+ if (easing == "exponentialOut") return via(easing::exponentialOut, vs...);
+ if (easing == "exponentialInOut") return via(easing::exponentialInOut, vs...);
+ if (easing == "circularIn") return via(easing::circularIn, vs...);
+ if (easing == "circularOut") return via(easing::circularOut, vs...);
+ if (easing == "circularInOut") return via(easing::circularInOut, vs...);
+ if (easing == "bounceIn") return via(easing::bounceIn, vs...);
+ if (easing == "bounceOut") return via(easing::bounceOut, vs...);
+ if (easing == "bounceInOut") return via(easing::bounceInOut, vs...);
+ if (easing == "elasticIn") return via(easing::elasticIn, vs...);
+ if (easing == "elasticOut") return via(easing::elasticOut, vs...);
+ if (easing == "elasticInOut") return via(easing::elasticInOut, vs...);
+ if (easing == "backIn") return via(easing::backIn, vs...);
+ if (easing == "backOut") return via(easing::backOut, vs...);
+ if (easing == "backInOut") return via(easing::backInOut, vs...);
+ return via(easing::def, vs...);
+ }
+
+ template<typename T>
+ template<typename... Fs>
+ tween <T> & tween<T>::via(const char * easing, Fs... vs) {
+ return via(std::string(easing));
+ }
+
template<typename T>
template<typename... Ds>
inline tween<T> & tween<T>::during(Ds... ds) {
@@ -72,7 +157,7 @@ namespace tweeny {
template<typename T>
inline const T & tween<T>::step(int32_t dt, bool suppress) {
- return step(static_cast<float>(dt * currentDirection)/static_cast<float>(total), suppress);
+ return step(static_cast<float>(dt)/static_cast<float>(total), suppress);
}
template<typename T>
@@ -82,6 +167,7 @@ namespace tweeny {
template<typename T>
inline const T & tween<T>::step(float dp, bool suppress) {
+ dp *= currentDirection;
seek(currentProgress + dp, true);
if (!suppress) dispatch(onStepCallbacks);
return current;
@@ -114,7 +200,7 @@ namespace tweeny {
template<typename T>
inline void tween<T>::interpolate(float prog, unsigned point, T & value) const {
auto & p = points.at(point);
- uint32_t pointDuration = p.duration() - (p.stacked - (prog * static_cast<float>(total)));
+ auto pointDuration = uint32_t(p.duration() - (p.stacked - (prog * static_cast<float>(total))));
float pointTotal = static_cast<float>(pointDuration) / static_cast<float>(p.duration());
if (pointTotal > 1.0f) pointTotal = 1.0f;
auto easing = std::get<0>(p.easings);
@@ -226,8 +312,8 @@ namespace tweeny {
}
template<typename T>
- inline const T & tween<T>::jump(int32_t p, bool suppress) {
- p = detail::clip(p, 0, static_cast<int>(points.size() -1));
+ inline const T & tween<T>::jump(size_t p, bool suppress) {
+ p = detail::clip(p, static_cast<size_t>(0), points.size() -1);
return seek(points.at(p).stacked, suppress);
}
@@ -238,11 +324,12 @@ namespace tweeny {
template<typename T> inline uint16_t tween<T>::pointAt(float progress) const {
- uint32_t t = static_cast<uint32_t>(progress * total);
+ progress = detail::clip(progress, 0.0f, 1.0f);
+ auto t = static_cast<uint32_t>(progress * total);
uint16_t point = 0;
while (t > points.at(point).stacked) point++;
if (point > 0 && t <= points.at(point - 1u).stacked) point--;
return point;
- };
+ }
}
#endif //TWEENY_TWEENONE_TCC
diff --git a/include/tweenpoint.h b/include/tweenpoint.h
index d6d4e26..732446c 100644
--- a/include/tweenpoint.h
+++ b/include/tweenpoint.h
@@ -1,7 +1,7 @@
/*
This file is part of the Tweeny library.
- Copyright (c) 2016-2018 Leonardo G. Lucena de Freitas
+ Copyright (c) 2016-2021 Leonardo Guilherme Lucena de Freitas
Copyright (c) 2016 Guilherme R. Costa
Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -23,7 +23,7 @@
*/
/*
- * This file provides the declarations for a tween currentPoint utility class. A tweenpoint holds the tween values,
+ * This file provides the declarations for a tween point utility class. A tweenpoint holds the tween values,
* easings and durations.
*/
@@ -40,7 +40,7 @@
namespace tweeny {
namespace detail {
/*
- * The tweenpoint class aids in the management of a tweening currentPoint by the tween class.
+ * The tweenpoint class aids in the management of a tweening point by the tween class.
* This class is private.
*/
template<typename... Ts>
@@ -56,10 +56,10 @@ namespace tweeny {
/* Constructs a tweenpoint from a set of values, filling their durations and easings */
tweenpoint(Ts... vs);
- /* Set the duration for all the values in this currentPoint */
+ /* Set the duration for all the values in this point */
template<typename D> void during(D milis);
- /* Sets the duration for each value in this currentPoint */
+ /* Sets the duration for each value in this point */
template<typename... Ds> void during(Ds... vs);
/* Sets the easing functions of each value */
diff --git a/include/tweenpoint.tcc b/include/tweenpoint.tcc
index 9817446..c5cda0e 100644
--- a/include/tweenpoint.tcc
+++ b/include/tweenpoint.tcc
@@ -1,7 +1,7 @@
/*
This file is part of the Tweeny library.
- Copyright (c) 2016-2018 Leonardo G. Lucena de Freitas
+ Copyright (c) 2016-2021 Leonardo Guilherme Lucena de Freitas
Copyright (c) 2016 Guilherme R. Costa
Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -69,7 +69,7 @@ namespace tweeny {
template<typename... Ts>
inline tweenpoint<Ts...>::tweenpoint(Ts... vs) : values{vs...} {
during(static_cast<uint16_t>(0));
- via(easing::linear);
+ via(easing::def);
}
template<typename... Ts>
@@ -82,7 +82,7 @@ namespace tweeny {
template<typename... Ds>
inline void tweenpoint<Ts...>::during(Ds... milis) {
static_assert(sizeof...(Ds) == sizeof...(Ts),
- "Amount of durations should be equal to the amount of values in a currentPoint");
+ "Amount of durations should be equal to the amount of values in a point");
std::array<int, sizeof...(Ts)> list = {{ milis... }};
std::copy(list.begin(), list.end(), durations.begin());
}
diff --git a/include/tweentraits.h b/include/tweentraits.h
index fc3194e..f9c7905 100644
--- a/include/tweentraits.h
+++ b/include/tweentraits.h
@@ -1,7 +1,7 @@
/*
This file is part of the Tweeny library.
- Copyright (c) 2016-2018 Leonardo G. Lucena de Freitas
+ Copyright (c) 2016-2021 Leonardo Guilherme Lucena de Freitas
Copyright (c) 2016 Guilherme R. Costa
Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -38,10 +38,11 @@ namespace tweeny {
namespace detail {
- template<typename... Ts> struct equal { enum { value = true }; };
- template<typename T> struct equal<T> { enum { value = true }; };
- template<typename T, typename... Ts> struct equal<T, T, Ts...> { enum { value = true && equal<Ts...>::value }; };
- template<typename T, typename U, typename... Ts> struct equal<T, U, Ts...> { enum { value = false }; };
+ template<typename... Ts> struct equal {};
+ template<typename T> struct equal<T> { enum { value = true }; };
+ template <typename T, typename U, typename... Ts> struct equal<T, U, Ts...> {
+ enum { value = std::is_same<T, U>::value && equal<T, Ts...>::value && equal<U, Ts...>::value };
+ };
template<typename T, typename...> struct first { typedef T type; };
diff --git a/include/tweeny.h b/include/tweeny.h
index ac6eeb3..3c7ba44 100644
--- a/include/tweeny.h
+++ b/include/tweeny.h
@@ -1,7 +1,7 @@
/*
This file is part of the Tweeny library.
- Copyright (c) 2016-2018 Leonardo G. Lucena de Freitas
+ Copyright (c) 2016-2021 Leonardo Guilherme Lucena de Freitas
Copyright (c) 2016 Guilherme R. Costa
Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -78,7 +78,6 @@
#ifndef TWEENY_H
#define TWEENY_H
-#include "tween.h"
#include "tween.h"
#include "easing.h"
diff --git a/include/tweeny.tcc b/include/tweeny.tcc
index f23224a..e2defac 100644
--- a/include/tweeny.tcc
+++ b/include/tweeny.tcc
@@ -1,7 +1,7 @@
/*
This file is part of the Tweeny library.
- Copyright (c) 2016-2018 Leonardo G. Lucena de Freitas
+ Copyright (c) 2016-2021 Leonardo Guilherme Lucena de Freitas
Copyright (c) 2016 Guilherme R. Costa
Permission is hereby granted, free of charge, to any person obtaining a copy of
diff --git a/src/sandbox.cc b/src/sandbox.cc
new file mode 100644
index 0000000..b1bea48
--- /dev/null
+++ b/src/sandbox.cc
@@ -0,0 +1,6 @@
+#include "tweeny.h"
+
+int main() {
+ auto tween1 = tweeny::from(0.0, 1.0f).to(1.0f, 0.0f).via("stepped", "linear");
+ return 0;
+}
\ No newline at end of file
Debdiff
[The following lists of changes regard files as different if they have different names, permissions or owners.]
Files in second set of .debs but not in first
-rw-r--r-- root/root /usr/share/doc/libtweeny-dev/html/classtweeny_1_1easing_a51ed8edf4a332ff98955d601000b29fd.html -rw-r--r-- root/root /usr/share/doc/libtweeny-dev/html/classtweeny_1_1tween_3_01T_01_4_a07a772f6726d2ede9c91f4df3f97f988.html -rw-r--r-- root/root /usr/share/doc/libtweeny-dev/html/classtweeny_1_1tween_3_01T_01_4_aaf3a9b6dde27df822d002c8b607a342d.html -rw-r--r-- root/root /usr/share/doc/libtweeny-dev/html/classtweeny_1_1tween_3_01T_01_4_abfa1c0a79172d1a915a98cbe6635072e.html -rw-r--r-- root/root /usr/share/doc/libtweeny-dev/html/classtweeny_1_1tween_3_01T_01_4_ad14e8692180aa76002a8e709459e9f89.html -rw-r--r-- root/root /usr/share/doc/libtweeny-dev/html/classtweeny_1_1tween_a4a65f7131472ba8ae0397ed77587c5f2.html -rw-r--r-- root/root /usr/share/doc/libtweeny-dev/html/functions_enum.html -rw-r--r-- root/root /usr/share/doc/libtweeny-dev/html/group__default.html -rw-r--r-- root/root /usr/share/doc/libtweeny-dev/html/group__stepped.html -rw-r--r-- root/root /usr/share/doc/libtweeny-dev/html/search/classes_7.html -rw-r--r-- root/root /usr/share/doc/libtweeny-dev/html/search/classes_7.js -rw-r--r-- root/root /usr/share/doc/libtweeny-dev/html/search/enums_0.html -rw-r--r-- root/root /usr/share/doc/libtweeny-dev/html/search/enums_0.js -rw-r--r-- root/root /usr/share/doc/libtweeny-dev/html/search/groups_6.html -rw-r--r-- root/root /usr/share/doc/libtweeny-dev/html/search/groups_6.js -rw-r--r-- root/root /usr/share/doc/libtweeny-dev/html/structtweeny_1_1easing_1_1defaultEasing-members.html -rw-r--r-- root/root /usr/share/doc/libtweeny-dev/html/structtweeny_1_1easing_1_1defaultEasing.html -rw-r--r-- root/root /usr/share/doc/libtweeny-dev/html/structtweeny_1_1easing_1_1steppedEasing-members.html -rw-r--r-- root/root /usr/share/doc/libtweeny-dev/html/structtweeny_1_1easing_1_1steppedEasing.html
Files in first set of .debs but not in second
-rw-r--r-- root/root /usr/share/doc/libtweeny-dev/html/classtweeny_1_1tween_3_01T_01_4_a1c228520a15aa0b8a2b2d57ed81cb49b.html -rw-r--r-- root/root /usr/share/doc/libtweeny-dev/html/classtweeny_1_1tween_a472eae275b937e97535a977d39f2bfb9.html -rw-r--r-- root/root /usr/share/doc/libtweeny-dev/html/classtweeny_1_1tween_aed261e74c8523a3da09abedc7e0daf12.html
No differences were encountered in the control files