From a91b026fd1d9173880ae39eb4fa271d878e66fa4 Mon Sep 17 00:00:00 2001 From: Tobias Gurdan Date: Fri, 6 Aug 2021 12:09:27 +0200 Subject: [PATCH 1/3] Fix lch hue wrapping typo --- src/interpolation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/interpolation.cpp b/src/interpolation.cpp index 00cbebd..95d5b11 100644 --- a/src/interpolation.cpp +++ b/src/interpolation.cpp @@ -66,7 +66,7 @@ lch_t lerp( const lch_t& lch1, const lch_t& lch2, const float t ) if ( delta.z > 180.f ) { delta.z -= 360.f; } else if ( delta.z < - 180.f ) { - delta.z += 380.f; + delta.z += 360.f; } auto interp = lch1 + t * delta; From 37dac51b9d8d65dacbdc51a60808c426affed8ae Mon Sep 17 00:00:00 2001 From: Tobias Gurdan Date: Fri, 6 Aug 2021 12:09:45 +0200 Subject: [PATCH 2/3] Add test for lch wrapping --- tests/CMakeLists.txt | 1 + tests/test_wrapping.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tests/test_wrapping.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index cdc3fb2..b34a716 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -11,6 +11,7 @@ set( SOURCES test_main.cpp test_conversion_manual.cpp test_profiles.cpp + test_wrapping.cpp ) set( DEPENDENCIES vivid ) diff --git a/tests/test_wrapping.cpp b/tests/test_wrapping.cpp new file mode 100644 index 0000000..ece6bc2 --- /dev/null +++ b/tests/test_wrapping.cpp @@ -0,0 +1,26 @@ +#include "utility.h" + +#include "vivid/interpolation.h" +#include "vivid/conversion.h" +#include "vivid/stream.h" + +#include "catch.hpp" + + +//////////////////////////////////////////////////////////////////////////////// +TEST_CASE( "Wrapping", "[interpolation]" ) +{ + using namespace vivid; + + SECTION( "LCH" ) + { + const lch_t colA { 10.f, 0.f, 10.f }; + const lch_t colB { 40.f, 20.f, 200.f }; + + const lch_t colAB = lerp( colA, colB, 0.5f ); + const lch_t colBA = lerp( colB, colA, 0.5f ); + + CAPTURE( colA, colB, colAB, colBA ); + REQUIRE( colAB == colBA ); + } +} \ No newline at end of file From 834a74bace1ff04ada273bbf486aae9fa7b1269a Mon Sep 17 00:00:00 2001 From: Tobias Gurdan Date: Fri, 6 Aug 2021 12:24:49 +0200 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6faae4c..f0f8000 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v3.0.1] - 2021-08-06 + +### Added +- Start interpolation and wrapping test cases + +### Fixed +- Faulty LCH interpolation wrapping [\#17](https://github.com/gurki/vivid/pull/17) + + ## [v3.0.0] - 2021-02-22 -## Added +### Added - Add interpolation in `Linear RGB` for `Color` - Add convenience `Color::linearRgb()` getter - Add gamma correction section and example to README