-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFillBar.cs
53 lines (48 loc) · 2.17 KB
/
FillBar.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using OpenWheels.Rendering;
namespace OpenWheels.Plotting
{
public class FillBar
{
public RectangleF Rectangle { get; set; }
public Direction Direction { get; set; }
public Color FillColor { get; set; }
public Color NotFillColor { get; set; }
public float Progress { get; set; }
public FillBar()
{
}
public void Draw(Batcher batcher)
{
Draw(batcher, Rectangle, Direction, FillColor, NotFillColor, Progress);
}
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);
}
}
}
}