forked from Caraxi/RemindMe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Common.cs
55 lines (41 loc) · 2.09 KB
/
Common.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
54
55
using System;
using System.Numerics;
using ImGuiNET;
using RemindMe.Config;
namespace RemindMe {
public partial class RemindMe {
public Vector4 GetBarBackgroundColor(MonitorDisplay display, DisplayTimer timer) {
if (!timer.IsComplete) return display.BarBackgroundColor;
if (!display.PulseReady) return timer.FinishedColor;
var s = (float) Math.Abs((Math.Abs((timer.TimerRemaining - display.CacheAge.TotalSeconds) / (2.5f - display.PulseSpeed)) - (float)Math.Floor(Math.Abs((timer.TimerRemaining - display.CacheAge.TotalSeconds) / (2.5f - display.PulseSpeed))) - 0.5f) / 2) * display.PulseIntensity;
if (timer.FinishedColor.W < 0.75) {
return timer.FinishedColor + new Vector4(0, 0, 0, s);
}
return timer.FinishedColor - new Vector4(0, 0, 0, s);
}
public void AddTextVertical(string text, uint textColor, float scale) {
var drawList = ImGui.GetWindowDrawList();
var pos = ImGui.GetCursorScreenPos();
var font = ImGui.GetFont();
var size = ImGui.CalcTextSize(text);
pos.X = (float)Math.Round(pos.X);
pos.Y = (float)Math.Round(pos.Y) + (float)Math.Round(size.X * scale);
foreach (var c in text) {
var glyph = font.FindGlyph(c);
drawList.PrimReserve(6, 4);
drawList.PrimQuadUV(
pos + new Vector2(glyph.Y0 * scale, -glyph.X0 * scale),
pos + new Vector2(glyph.Y0 * scale, -glyph.X1 * scale),
pos + new Vector2(glyph.Y1 * scale, -glyph.X1 * scale),
pos + new Vector2(glyph.Y1 * scale, -glyph.X0 * scale),
new Vector2(glyph.U0, glyph.V0),
new Vector2(glyph.U1, glyph.V0),
new Vector2(glyph.U1, glyph.V1),
new Vector2(glyph.U0, glyph.V1),
textColor);
pos.Y -= glyph.AdvanceX * scale;
}
ImGui.Dummy(new Vector2(size.Y, size.X));
}
}
}