public static void Draw(Batcher batcher, RectangleF rect, Direction direction, Color fill, Color notFill, float progress) { switch (direction) { case Direction.Up: batcher.DrawBarUp(rect.Center.X, rect.Bottom, rect.Height * progress, fill, rect.Width); if (notFill.A != 0) { batcher.DrawBarDown(rect.Center.X, rect.Top, rect.Height * (1f - progress), notFill, rect.Width); } break; case Direction.Right: batcher.DrawBarRight(rect.Center.Y, rect.Left, rect.Width * progress, fill, rect.Height); if (notFill.A != 0) { batcher.DrawBarLeft(rect.Center.Y, rect.Right, rect.Width * (1f - progress), notFill, rect.Height); } break; case Direction.Down: batcher.DrawBarDown(rect.Center.X, rect.Top, rect.Height * progress, fill, rect.Width); if (notFill.A != 0) { batcher.DrawBarUp(rect.Center.X, rect.Bottom, rect.Height * (1f - progress), notFill, rect.Width); } break; case Direction.Left: batcher.DrawBarLeft(rect.Center.Y, rect.Right, rect.Width * progress, fill, rect.Height); if (notFill.A != 0) { batcher.DrawBarRight(rect.Center.Y, rect.Left, rect.Width * (1f - progress), notFill, rect.Height); } break; default: throw new ArgumentOutOfRangeException(nameof(direction), direction, null); } }
public static void Draw(Batcher batcher, RectangleF rect, float barWidth, float barSpacing, IEnumerable <float> values, Color color) { var x = rect.Left + barWidth / 2; foreach (var v in values) { if (x + barWidth / 2 > rect.Right) { break; } if (v < 0) { continue; } var clamped = v > 1 ? 1 : v; var height = rect.Height * clamped; batcher.DrawBarUp(x, rect.Bottom, height, color, barWidth); x += barWidth + barSpacing; } }