31 float hidden_width = (360 - range) / range *
panel_size.x;
32 float total_width =
panel_size.x + hidden_width;
33 float original_width = width;
37 mirror_width =
min(
fabs(offset), width);
38 mirror_offset = offset + total_width;
44 mirror_offset = offset - total_width;
45 mirror_width =
min(mirror_offset + width, width);
46 if (mirror_offset < 0)
50 float overflow_width = offset + width -
panel_size.x;
51 width =
max(width, 0);
52 if (overflow_width > 0)
60 float original_offset = offset;
71 if (mirror_offset < 0)
73 mirror_width += mirror_offset;
77 float overflow_mirror_width = mirror_offset + mirror_width -
panel_size.x;
78 mirror_width =
max(mirror_width, 0);
79 if (overflow_mirror_width > 0)
82 overflow_mirror_width = 0;
85 mirror_size.x = mirror_width;
87 float original_mirror_offset = mirror_offset;
92 if (mirror_size.x > 0)
102 if (mirror_size.x > 0 && mirror_size.y > 0)
109 if (mirror_size.x > 0 && mirror_size.y > 0)
112 mirror_size,
"progressbar",
126 float gradient_offset, gradient_mirror_offset;
128 if (offset == 0 && mirror_offset == 0)
129 gradient_start = width > mirror_width ? 2 : 1;
130 else if (offset == 0)
132 else if (mirror_offset == 0)
137 switch (gradient_start)
141 gradient_offset = gradient_mirror_offset = 0;
145 gradient_mirror_offset = original_width - (mirror_width + overflow_mirror_width);
148 gradient_offset = original_width - (width + overflow_width);
149 gradient_mirror_offset = 0;
154 if (mirror_size.x > 0)
157 mirror_size, original_width, mirror_offset,
alpha,
158 gradient_mirror_offset, gradient_type, range);
163 gradient_offset, gradient_type, range);
167 if (mirror_size.x > 0)
170 mirror_size, original_width, mirror_offset, original_mirror_offset,
171 alpha, gradient_mirror_offset, gradient_type, range);
175 size, original_width, offset, original_offset,
176 alpha, gradient_offset, gradient_type, range);
185 float offset,
float alpha,
float gradient_offset,
int gradient_type,
float range)
189 original_width *= 0.5;
192 size1.x =
bound(0, original_width - gradient_offset,
size.x);
195 size2.x =
size.x - size1.x;
205 vector gradient_start =
eX * offset;
208 vector gradient_end = gradient_start +
eX * gradient_width;
213 if (alpha1 + alpha2 == 0)
216 float ratio1 = gradient_offset / original_width;
217 float ratio2 = (gradient_offset +
size.x) / original_width;
225 gradient_start.x =
HUD_ScaleX(gradient_start.x);
227 gradient_height.y =
HUD_ScaleY(gradient_height.y);
230 R_PolygonVertex(
origin + gradient_start,
'0 0 0', color1, alpha1 * (1 - ratio1));
231 R_PolygonVertex(
origin + gradient_start + gradient_height,
'0 0 0', color1, alpha1 * (1 - ratio1));
232 R_PolygonVertex(
origin + gradient_end + gradient_height,
'0 0 0', color1, alpha1 * (1 - ratio2));
233 R_PolygonVertex(
origin + gradient_end,
'0 0 0', color1, alpha1 * (1 - ratio2));
237 R_PolygonVertex(
origin + gradient_start,
'0 0 0', color2, alpha2 * ratio1);
238 R_PolygonVertex(
origin + gradient_start + gradient_height,
'0 0 0', color2, alpha2 * ratio1);
239 R_PolygonVertex(
origin + gradient_end + gradient_height,
'0 0 0', color2, alpha2 * ratio2);
240 R_PolygonVertex(
origin + gradient_end,
'0 0 0', color2, alpha2 * ratio2);
247 float alpha,
float gradient_offset,
int gradient_type,
float range)
251 if (alpha1 == 0 && alpha2 == 0)
254 float color_ratio = alpha1 / (alpha1 + alpha2);
256 for (
int i = 0; i <
size.x; ++i)
258 segment_size.x =
min(
size.x - i, 1);
259 float segment_offset = offset + i;
260 float ratio_offset = segment_offset + segment_size.x / 2;
262 ratio_offset += gradient_offset;
263 float ratio = (ratio_offset - original_offset) / original_width * (gradient_type ==
STRAFEHUD_GRADIENT_BOTH ? 2 : 1);
268 float alpha_ratio = alpha1 - (alpha1 - alpha2) * ratio;
269 float combine_ratio1 = ratio * (1 - color_ratio);
270 float combine_ratio2 = (1 - ratio) * color_ratio;
271 ratio = (combine_ratio1 + combine_ratio2) == 0 ? 1 : combine_ratio1 / (combine_ratio1 + combine_ratio2);
294 if (connection_width > 0)
310 vector pos,
float offset_top,
float offset_bottom)
324 pos.y +=
size.y + offset_top;
327 else if (pos.y <= -1)
void drawstring_aspect(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag)
#define drawfill(position, size, rgb, alpha, flag)
void StrafeHUD_DrawStrafeArrow(vector origin, float size, vector color, float alpha, bool flipped, float connection_width)
void StrafeHUD_DrawStrafeHUD(float startangle, float offsetangle, vector color, float alpha, int type, int gradient_type, float range)
void StrafeHUD_DrawSoftGradient(vector color1, vector color2, vector size, float original_width, float offset, float original_offset, float alpha, float gradient_offset, int gradient_type, float range)
void StrafeHUD_DrawGradient(vector color1, vector color2, vector size, float original_width, float offset, float alpha, float gradient_offset, int gradient_type, float range)
void StrafeHUD_DrawTextIndicator(string text, float height, vector color, float fadetime, float lasttime, vector pos, float offset_top, float offset_bottom)
bool StrafeHUD_IsGradient(int style)
vector StrafeHUD_CalculateTextIndicatorPosition(vector pos)
float StrafeHUD_ProjectWidth(float offset, float width, float range)
float StrafeHUD_AngleToWidth(float angle, float range)
float StrafeHUD_AngleToOffset(float angle, float range)
vector StrafeHUD_MixColors(vector color1, vector color2, float ratio)
float StrafeHUD_ProjectOffset(float offset, float range, bool reverse)
const float DRAWFLAG_NORMAL
void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, bool vertical, float baralign, vector theColor, float theAlpha, int drawflag)
vector HUD_Shift(vector v)
const int STRAFEHUD_STYLE_GRADIENT
const int STRAFEHUD_GRADIENT_RIGHT
const int STRAFEHUD_GRADIENT_NONE
const int STRAFEHUD_STYLE_SOFT_GRADIENT
float autocvar_hud_panel_strafehud_bar_neutral_alpha
const int STRAFEHUD_GRADIENT_BOTH
const int STRAFEHUD_STYLE_DRAWFILL
const int STRAFEHUD_GRADIENT_LEFT
vector autocvar_hud_panel_strafehud_bar_neutral_color
const int STRAFEHUD_STYLE_PROGRESSBAR