-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterval.cs
More file actions
66 lines (49 loc) · 1.64 KB
/
Copy pathInterval.cs
File metadata and controls
66 lines (49 loc) · 1.64 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FluxLightUI
{
class Interval
{
public int[] startColor;
public int[] endColor;
public DateTime start;
public DateTime end;
protected double[] interval;
public Interval(DateTime from, DateTime to, int[] sc, int[] ec)
{
start = new DateTime(2000, 1, 1, from.Hour, from.Minute, from.Second);
end = new DateTime(2000, 1, 1, to.Hour, to.Minute, to.Second);
startColor = sc;
endColor = ec;
//interval = getColorInterval(startColor, endColor);
}
public int[] getColor()
{
double minutesFromStart = DateTime.Now.TimeOfDay.Subtract(start.TimeOfDay).TotalMinutes;
return new int[] {
(int)Math.Abs(startColor[0] - (minutesFromStart * interval[0])),
(int)Math.Abs(startColor[1] - (minutesFromStart * interval[1])),
(int)Math.Abs(startColor[2] - (minutesFromStart * interval[2]))
};
}
public double[] getColorInterval(int[] s, int[] e)
{
double minutes = end.TimeOfDay.Subtract(start.TimeOfDay).TotalMinutes;
double r = (s[0] - e[0]) / minutes;
double g = (s[1] - e[1]) / minutes;
double b = (s[2] - e[2]) / minutes;
return new double[] { r, g, b };
}
public DateTime getStart()
{
return start;
}
public DateTime getEnd()
{
return end;
}
}
}