如何通过每种颜色的分数贡献在n种颜色之间插值?
如何在n种颜色之间插值。
How can I interpolate between n colors.
两种颜色的简单案例
先考虑一个更简单的案例,我们要找到两种颜色的中点。
Consider a more simple case first, where we want to find the mid-point of 2 colors.
Color1 is RGB ( 255, 0, 0 ) // Red
Color2 is RGB ( 128, 128, 128 ) // Grey
RGB ( 128 + 64, 128 / 2, 128 / 2 ) = RGB ( 192, 64, 64 )
由于中点正好在两者之间,与插值存在线性关系,那么它可以通过在Color1和Color2之间的小数量(例如0.25)进行插值,颜色应该更接近Color1。
Since the mid-point is exactly in between the two and there is a linear relationship to the interpolation, then its possiable to interpolate by a fractional amount such as 0.25 between Color1 and Color2, the color should be closer to Color1.
RGB ( 255 - 32, 32, 32 ) = RGB ( 223, 32, 32 )
b $ b
n种颜色的情况
我希望找到解决方案的案例是有n种颜色,具有最多为1.0的分数加权。
The case I wish to find a solution for is where there are n colors where each color has a fractional weighting totaling up to 1.0.
(猜测,我猜每种颜色可以被认为是3维空间中的一个点,内插点对每个色点)
(Guessing, I guess each color could be considered to be a point in a 3 dimensional space and the weighting describes how far relatively the interpolated point is to each color point)
颜色插值只是线性RGB。
The color interpolation is linear RGB only.
在某些情况下我想有可能是多个整数值的解决方案的问题,例如,如果有几个颜色具有相似的值。
Under some conditions I guess there MAY be multiple integer values which are solutions to the problem, for example if there are a n few colors which have similar value.
我读到有双线性
通常颜色数不会超过5,通常是2,3或4种颜色。
Usually the number of colors wouldn't exceed 5, it would usually be 2, 3 or 4 colors.
一些解决问题的Java代码位于这里,注意它是用Scala SBT构建的,但是它的Java代码。
Some Java code which solves the problem is located here, note that it builds with Scala SBT but its Java code.
https://github.com/PhilAndrew/betweenrgb
加权颜色的合并在这里测试:
The merging of weighted colors is tested here: