]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
strafehud: make gradient segments calculate their appearance using the center of...
authorJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Fri, 3 Feb 2023 23:53:02 +0000 (00:53 +0100)
committerJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Fri, 3 Feb 2023 23:54:22 +0000 (00:54 +0100)
qcsrc/client/hud/panel/strafehud.qc

index 620a22ff0f9bfd8fd5180600fd3472aa6c075923..32c175c35194154a9084e486befcb9feafc23449 100644 (file)
@@ -1082,7 +1082,7 @@ void StrafeHUD_drawGradient(vector color1, vector color2, vector size, float ori
     {
         float ratio, alpha_ratio, combine_ratio1, combine_ratio2;
         segment_size.x = min(size.x - i, 1); // each gradient segment is 1 unit wide except if there is less than 1 unit of gradient remaining
-        ratio = (i + gradientOffset) / original_width * (gradientType == STRAFEHUD_GRADIENT_BOTH ? 2 : 1);
+        ratio = (i + segment_size.x/2 + gradientOffset) / original_width * (gradientType == STRAFEHUD_GRADIENT_BOTH ? 2 : 1);
         if(ratio > 1) ratio = 2 - ratio;
         if(gradientType != STRAFEHUD_GRADIENT_RIGHT) ratio = 1 - ratio;
         alpha_ratio = alpha1 - (alpha1 - alpha2) * ratio;