diff options
author | Hans Goudey <h.goudey@me.com> | 2022-03-30 03:44:01 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-03-30 03:45:59 +0300 |
commit | 72d25fa41d8c5753e4cdc1293d407e16c1431119 (patch) | |
tree | c074afbdab6a1b274ef659e2aeb463ef12c578b4 /source/blender/blenlib/BLI_math_color.hh | |
parent | bcb9379c6dfadbc7883f6f93bcca6a8b2a113419 (diff) |
Curves: Add length cache, length paramerterize utility
This commit adds calculation of lengths along the curve for each
evaluated point. This is used for sampling, resampling, the "curve
parameter" node, and potentially more places in the future.
This commit also includes a utility for calculation of uniform samples
in blenlib. It can find evenlyspaced samples along a sequence of points
and use linear interpolation to move data from those points to the
samples. Making the utility more general aligns better with the more
functional approach of the new curves code and makes the behavior
available elsewhere.
A "color math" header is added to allow very basic interpolation
between two colors in the `blender::math` namespace.
Differential Revision: https://developer.blender.org/D14382
Diffstat (limited to 'source/blender/blenlib/BLI_math_color.hh')
-rw-r--r-- | source/blender/blenlib/BLI_math_color.hh | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_color.hh b/source/blender/blenlib/BLI_math_color.hh new file mode 100644 index 00000000000..5195cfb6238 --- /dev/null +++ b/source/blender/blenlib/BLI_math_color.hh @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2022 Blender Foundation. */ + +#pragma once + +/** \file + * \ingroup bli + */ + +#include <cmath> +#include <type_traits> + +#include "BLI_color.hh" +#include "BLI_math_base.hh" + +namespace blender::math { + +inline ColorGeometry4f interpolate(const ColorGeometry4f &a, + const ColorGeometry4f &b, + const float t) +{ + return {math::interpolate(a.r, b.r, t), + math::interpolate(a.g, b.g, t), + math::interpolate(a.b, b.b, t), + math::interpolate(a.a, b.a, t)}; +} + +} // namespace blender::math |