- float ratio = static_cast<float>(j-segmentStart)/segmentWidth;
- Vector4 currentColor = mGradientStops[i].mStopColor * (1.f-ratio) + mGradientStops[i+1].mStopColor * ratio;
- pixels[k*4] = static_cast<unsigned char>( 255.f * Clamp( currentColor.r, 0.f, 1.f ) );
- pixels[k*4+1] = static_cast<unsigned char>( 255.f * Clamp( currentColor.g, 0.f, 1.f ) );
- pixels[k*4+2] = static_cast<unsigned char>( 255.f * Clamp( currentColor.b, 0.f, 1.f ) );
- pixels[k*4+3] = static_cast<unsigned char>( 255.f * Clamp( currentColor.a, 0.f, 1.f ) );
+ float ratio = static_cast<float>(j - segmentStart) / (segmentWidth - 1);
+ Vector4 currentColor = mGradientStops[i].mStopColor * (1.f - ratio) + mGradientStops[i + 1].mStopColor * ratio;
+ pixels[k * 4] = static_cast<unsigned char>(255.f * Clamp(currentColor.r, 0.f, 1.f));
+ pixels[k * 4 + 1] = static_cast<unsigned char>(255.f * Clamp(currentColor.g, 0.f, 1.f));
+ pixels[k * 4 + 2] = static_cast<unsigned char>(255.f * Clamp(currentColor.b, 0.f, 1.f));
+ pixels[k * 4 + 3] = static_cast<unsigned char>(255.f * Clamp(currentColor.a, 0.f, 1.f));