public void NewProgressBarResults(Control f, string label, float value, float maxValue, ref Vector2 elementPosition, string customText) { if (maxValue <= 0) { return; } System.Drawing.Color color = System.Drawing.Color.Red; if (value <= maxValue) { System.Drawing.Color color1 = System.Drawing.Color.Red, color2 = System.Drawing.Color.Yellow, color3 = System.Drawing.Color.Green; float halfWay = maxValue / 2f; float v = value; if (v >= halfWay) { color1 = color2; color2 = color3; v -= halfWay; } var i = new Common.Interpolator4(); i.AddKey(new Common.InterpolatorKey <Vector4> { Time = 0, Value = Common.Math.ToVector4(color1) }); i.AddKey(new Common.InterpolatorKey <Vector4> { Time = 1, Value = Common.Math.ToVector4(color2) }); color = Common.Math.ToColor(i.Update(v / halfWay)); } float pbSize = 18; var pb = new ProgressBar { Size = new Vector2(rightHandWidth, pbSize), Text = customText, MaxValue = maxValue, Value = value, Anchor = global::Graphics.Orientation.TopLeft, ProgressGraphic = new Graphics.Content.StretchingImageGraphic { Texture = new Graphics.Content.TextureConcretizer { TextureDescription = new global::Graphics.Software.Textures.SingleColorTexture(color) } }, Font = statTextFont }; NewResults(f, label, pb, ref elementPosition); }
public void NewProgressBarResults(Control f, string label, float value, float maxValue, ref Vector2 elementPosition, string customText) { if (maxValue <= 0) return; System.Drawing.Color color = System.Drawing.Color.Red; if (value <= maxValue) { System.Drawing.Color color1 = System.Drawing.Color.Red, color2 = System.Drawing.Color.Yellow, color3 = System.Drawing.Color.Green; float halfWay = maxValue / 2f; float v = value; if (v >= halfWay) { color1 = color2; color2 = color3; v -= halfWay; } var i = new Common.Interpolator4(); i.AddKey(new Common.InterpolatorKey<Vector4> { Time = 0, Value = Common.Math.ToVector4(color1) }); i.AddKey(new Common.InterpolatorKey<Vector4> { Time = 1, Value = Common.Math.ToVector4(color2) }); color = Common.Math.ToColor(i.Update(v / halfWay)); } float pbSize = 18; var pb = new ProgressBar { Size = new Vector2(rightHandWidth, pbSize), Text = customText, MaxValue = maxValue, Value = value, Anchor = global::Graphics.Orientation.TopLeft, ProgressGraphic = new Graphics.Content.StretchingImageGraphic { Texture = new Graphics.Content.TextureConcretizer { TextureDescription = new global::Graphics.Software.Textures.SingleColorTexture(color) } }, Font = statTextFont }; NewResults(f, label, pb, ref elementPosition); }