;
public Vec4 interpolate(float alpha) {
if ( values.isEmpty() ) {
new Vec4();
}
if ( values.size() == 1 ) {
return new Vec4( values.get( 0 ).data );
}
// Find which segment we are within.
int segment = 1;
for (; segment < values.size(); segment++ ) {
if ( alpha < values.get( segment ).weight ) {
break;
}
}
if ( segment == values.size() ) {
return new Vec4( values.get( segment - 1 ).data );
}
float sectionAlpha = alpha - values.get( segment - 1 ).weight;
sectionAlpha /= values.get( segment ).weight - values.get( segment - 1 ).weight;