Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/faulty lch interpolation wrapping #17

Merged
merged 3 commits into from
Aug 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/interpolation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ set( SOURCES
test_main.cpp
test_conversion_manual.cpp
test_profiles.cpp
test_wrapping.cpp
)

set( DEPENDENCIES vivid )
Expand Down
26 changes: 26 additions & 0 deletions tests/test_wrapping.cpp
Original file line number Diff line number Diff line change
@@ -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 );
}
}