This commit is contained in:
TinyHerm committed 2026-11-24 23:40:08 +03:00
commit 1c7a8cf25f
579 files changed
+83196

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
namespace VibranceHud.Design;
public enum BackdropLook
{
Blossom,
Soft,
Off
}
+31
View File
@@ -0,0 +1,31 @@
using System;
namespace VibranceHud.Design;
public static class BackdropLooks
{
internal static Action<string>? FailPointForTest { get; set; }
public static string Name(BackdropLook look)
{
return look.ToString();
}
public static BackdropLook Parse(string? stored)
{
string text = (stored ?? "").Trim();
if (text.Length == 0 || char.IsDigit(text[0]) || text[0] == '-')
{
return BackdropLook.Blossom;
}
if (text.Contains(','))
{
return BackdropLook.Blossom;
}
if (!Enum.TryParse<BackdropLook>(text, ignoreCase: true, out var result) || !Enum.IsDefined(result))
{
return BackdropLook.Blossom;
}
return result;
}
}
+241
View File
@@ -0,0 +1,241 @@
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using VibranceHud.Theming;
namespace VibranceHud.Design;
public sealed class BlossomBough : IBackdrop
{
private readonly record struct Depth(int Divisor, float Scale, int Alpha, int Clusters, int PerCluster, int Seed);
private Bitmap? _cache;
private string _cacheKey = "";
private int _w;
private int _h;
private static readonly Depth[] Layers = new Depth[3]
{
new Depth(10, 0.34f, 58, 17, 11, 11),
new Depth(6, 0.44f, 72, 14, 9, 29),
new Depth(4, 0.62f, 82, 10, 7, 47)
};
internal int CacheBuilds { get; private set; }
public bool Moves => false;
public void Resize(int w, int h)
{
_w = Math.Max(1, w);
_h = Math.Max(1, h);
}
public void Update(double dtSeconds)
{
}
public void Paint(Graphics g, int offsetX, int offsetY)
{
if (_w > 1 && _h > 1)
{
EnsureCache();
if (_cache != null)
{
g.DrawImageUnscaled(_cache, -offsetX, -offsetY);
}
}
}
private void EnsureCache()
{
string text = Theme.CurrentName + "|" + _w + "x" + _h + (AppBackground.IsSet ? "|img" : "");
if (_cache != null && _cacheKey == text)
{
return;
}
_cache?.Dispose();
_cache = null;
_cacheKey = text;
CacheBuilds++;
using Bitmap bitmap = new Bitmap(_w, _h);
using (Graphics graphics = Graphics.FromImage(bitmap))
{
graphics.Clear(Color.Transparent);
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
int strength = ((!AppBackground.IsSet) ? 1 : 3);
Depth[] layers = Layers;
foreach (Depth depth in layers)
{
DrawLayer(graphics, depth, strength);
}
}
FadeDownward(bitmap);
_cache = Premultiplied(bitmap);
}
private static Bitmap Premultiplied(Bitmap argb)
{
Bitmap bitmap = new Bitmap(argb.Width, argb.Height, PixelFormat.Format32bppPArgb);
using Graphics graphics = Graphics.FromImage(bitmap);
graphics.CompositingMode = CompositingMode.SourceCopy;
graphics.DrawImageUnscaled(argb, 0, 0);
return bitmap;
}
private static void FadeDownward(Bitmap bmp)
{
Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
BitmapData bitmapData = bmp.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
try
{
int stride = bitmapData.Stride;
byte[] array = new byte[stride];
for (int i = 0; i < bmp.Height; i++)
{
float num = (float)i / (float)Math.Max(1, bmp.Height);
float num2;
if (num <= 0.14f)
{
num2 = 1f;
}
else
{
num2 = ((num >= 0.58f) ? 0f : (1f - (num - 0.14f) / 0.44f));
}
if (!(num2 >= 0.999f))
{
nint num3 = bitmapData.Scan0 + i * stride;
Marshal.Copy(num3, array, 0, stride);
for (int j = 3; j < stride; j += 4)
{
array[j] = (byte)((float)(int)array[j] * num2);
}
Marshal.Copy(array, 0, num3, stride);
}
}
}
finally
{
bmp.UnlockBits(bitmapData);
}
}
private void DrawLayer(Graphics g, Depth depth, int strength)
{
int num = Math.Max(2, _w / depth.Divisor);
int num2 = Math.Max(2, _h / depth.Divisor);
using Bitmap image = new Bitmap(num, num2);
using (Graphics graphics = Graphics.FromImage(image))
{
graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.Clear(Color.Transparent);
PaintBough(graphics, num, num2, depth, strength);
}
using ImageAttributes imageAttributes = new ImageAttributes();
imageAttributes.SetWrapMode(WrapMode.TileFlipXY);
g.DrawImage(image, new Rectangle(0, 0, _w, _h), 0, 0, num, num2, GraphicsUnit.Pixel, imageAttributes);
}
private static void PaintBough(Graphics g, int w, int h, Depth depth, int strength)
{
Random random = new Random(depth.Seed);
Color petal = Color.FromArgb(depth.Alpha / strength, Theme.PlexusNodeA);
Color centre = Color.FromArgb(depth.Alpha / (strength * 2), Theme.PlexusNodeB);
Color color = Color.FromArgb(Math.Min(255, depth.Alpha + 78) / strength, Theme.PlexusLine);
PointF[][] array = new PointF[2][]
{
new PointF[4]
{
new PointF(-0.06f, 0.1f),
new PointF(0.28f, 0.3f),
new PointF(0.58f, 0.02f),
new PointF(1.06f, 0.22f)
},
new PointF[4]
{
new PointF(0.1f, -0.05f),
new PointF(0.2f, 0.26f),
new PointF(0.16f, 0.52f),
new PointF(0.26f, 0.86f)
}
};
float width = Math.Max(1.6f, (float)w * 0.02f * depth.Scale);
using (Pen pen = new Pen(color, width)
{
LineJoin = LineJoin.Round,
StartCap = LineCap.Round,
EndCap = LineCap.Round
})
{
PointF[][] array2 = array;
foreach (PointF[] array3 in array2)
{
g.DrawBezier(pen, array3[0].X * (float)w, array3[0].Y * (float)h, array3[1].X * (float)w, array3[1].Y * (float)h, array3[2].X * (float)w, array3[2].Y * (float)h, array3[3].X * (float)w, array3[3].Y * (float)h);
}
}
PointF[] p = array[0];
float num = Math.Max(2f, (float)w * 0.02f * depth.Scale);
for (int j = 0; j < depth.Clusters; j++)
{
float t = ((float)j + 0.5f) / (float)depth.Clusters;
PointF pointF = Bezier(p, t);
float num2 = pointF.X * (float)w + (float)(random.NextDouble() - 0.5) * (float)w * 0.06f;
float num3 = pointF.Y * (float)h + (float)(random.NextDouble() - 0.5) * (float)h * 0.1f;
for (int k = 0; k < depth.PerCluster; k++)
{
Flower(g, num2 + (float)(random.NextDouble() - 0.5) * num * 3.4f, num3 + (float)(random.NextDouble() - 0.5) * num * 3f, num * (0.7f + (float)random.NextDouble() * 0.6f), petal, centre, (float)random.NextDouble() * 72f);
}
}
for (int l = 0; l < Math.Max(2, depth.Clusters / 3); l++)
{
PointF pointF2 = Bezier(array[1], ((float)l + 1f) / ((float)depth.Clusters / 3f + 1f));
for (int m = 0; m < depth.PerCluster - 1; m++)
{
Flower(g, pointF2.X * (float)w + (float)(random.NextDouble() - 0.5) * num * 3.2f, pointF2.Y * (float)h + (float)(random.NextDouble() - 0.5) * num * 2.8f, num * (0.6f + (float)random.NextDouble() * 0.5f), petal, centre, (float)random.NextDouble() * 72f);
}
}
}
private static PointF Bezier(PointF[] p, float t)
{
float num = 1f - t;
float num2 = num * num * num;
float num3 = 3f * num * num * t;
float num4 = 3f * num * t * t;
float num5 = t * t * t;
return new PointF(num2 * p[0].X + num3 * p[1].X + num4 * p[2].X + num5 * p[3].X, num2 * p[0].Y + num3 * p[1].Y + num4 * p[2].Y + num5 * p[3].Y);
}
private static void Flower(Graphics g, float cx, float cy, float r, Color petal, Color centre, float rotation)
{
if (r <= 0.4f)
{
return;
}
GraphicsState gstate = g.Save();
g.TranslateTransform(cx, cy);
g.RotateTransform(rotation);
using (SolidBrush brush = new SolidBrush(petal))
{
for (int i = 0; i < 5; i++)
{
GraphicsState gstate2 = g.Save();
g.RotateTransform((float)i * 72f);
g.FillEllipse(brush, (0f - r) * 0.55f, (0f - r) * 1.02f, r * 1.1f, r * 0.9f);
g.Restore(gstate2);
}
}
using (SolidBrush brush2 = new SolidBrush(centre))
{
g.FillEllipse(brush2, (0f - r) * 0.26f, (0f - r) * 0.26f, r * 0.52f, r * 0.52f);
}
g.Restore(gstate);
}
}
+7
View File
@@ -0,0 +1,7 @@
namespace VibranceHud.Design;
public enum Chrome
{
Plexus,
Blossom
}
+29
View File
@@ -0,0 +1,29 @@
using System;
namespace VibranceHud.Design;
public static class Chromes
{
public static string Name(Chrome chrome)
{
return chrome.ToString();
}
public static Chrome Parse(string? stored)
{
string text = (stored ?? "").Trim();
if (text.Length == 0 || char.IsDigit(text[0]) || text[0] == '-')
{
return Chrome.Plexus;
}
if (text.Contains(','))
{
return Chrome.Plexus;
}
if (!Enum.TryParse<Chrome>(text, ignoreCase: true, out var result) || !Enum.IsDefined(result))
{
return Chrome.Plexus;
}
return result;
}
}
+18
View File
@@ -0,0 +1,18 @@
namespace VibranceHud.Design;
public enum FontRole
{
Value,
Display,
Title,
Heading,
HeadingRegular,
Body,
BodyBold,
Label,
LabelBold,
Caption,
CaptionBold,
Micro,
Mono
}
+197
View File
@@ -0,0 +1,197 @@
using System;
using System.Drawing;
namespace VibranceHud.Design;
public static class Fonts
{
private const string SemiboldFaceSuffix = " Semibold";
private static readonly Font?[] _cache = new Font[Enum.GetValues<FontRole>().Length];
private static string? _semiboldFamily;
private static float _pointScale = 1f;
private static string? _monoFamily;
private static TypeStep CaptionStep => new TypeStep(12, 16, 400);
private static TypeStep CaptionStrongStep => new TypeStep(12, 16, 600);
private static TypeStep BodyStep => new TypeStep(14, 20, 400);
private static TypeStep BodyStrongStep => new TypeStep(14, 20, 600);
private static TypeStep SubtitleStep => new TypeStep(20, 28, 600);
private static TypeStep TitleStep => new TypeStep(28, 36, 600);
private static TypeStep ValueStep => new TypeStep(40, 48, 600);
public static float PointScaleForOffscreenRenders
{
get
{
return _pointScale;
}
set
{
if (!(value >= 0.5f) || !(value <= 4f))
{
throw new ArgumentOutOfRangeException("value", value, "a render scale outside 0.5 to 4 is a mistake, not a monitor");
}
_pointScale = value;
}
}
public static Font Value => Get(FontRole.Value);
public static Font Display => Get(FontRole.Display);
public static Font Title => Get(FontRole.Title);
public static Font Heading => Get(FontRole.Heading);
public static Font Body => Get(FontRole.Body);
public static Font Label => Get(FontRole.Label);
public static Font Caption => Get(FontRole.Caption);
public static Font Micro => Get(FontRole.Micro);
public static Font Mono => Get(FontRole.Mono);
public static Font BodyBold => Get(FontRole.BodyBold);
public static Font LabelBold => Get(FontRole.LabelBold);
public static Font CaptionBold => Get(FontRole.CaptionBold);
public static Font HeadingRegular => Get(FontRole.HeadingRegular);
public static string MonoFamily => _monoFamily ?? (_monoFamily = ResolveFamilyOrGenericMono(SignalTokens.Root.FontMonoFamilies));
public static string SemiboldFamily => _semiboldFamily ?? (_semiboldFamily = SemiboldFamilyFor(Theme.FontFamily));
public static TypeStep Step(FontRole role)
{
return role switch
{
FontRole.Value => ValueStep,
FontRole.Display => TitleStep,
FontRole.Title => SubtitleStep,
FontRole.Heading => BodyStrongStep,
FontRole.HeadingRegular => BodyStep,
FontRole.Body => BodyStep,
FontRole.BodyBold => BodyStrongStep,
FontRole.Label => BodyStep,
FontRole.LabelBold => BodyStrongStep,
FontRole.Caption => CaptionStep,
FontRole.CaptionBold => CaptionStrongStep,
FontRole.Mono => BodyStep,
_ => CaptionStrongStep,
};
}
public static float PointsFor(FontRole role)
{
return (float)Step(role).SizePx * 72f / 96f * _pointScale;
}
public static int LineHeight(FontRole role)
{
return Tokens.Scale(Step(role).LinePx);
}
public static Font For(FontRole role)
{
return Get(role);
}
public static Font Of(FontRole role, string family)
{
return Make(Step(role), family);
}
private static Font Get(FontRole role)
{
ref Font reference = ref _cache[(int)role];
return reference ?? (reference = Make(Step(role), (role == FontRole.Mono) ? MonoFamily : Theme.FontFamily));
}
private static Font Make(TypeStep step, string family)
{
float emSize = (float)step.SizePx * 72f / 96f * _pointScale;
if (step.Weight < 600)
{
return new Font(family, emSize, FontStyle.Regular);
}
string text = SemiboldFamilyFor(family);
if (!(text == family))
{
return new Font(text, emSize, FontStyle.Regular);
}
return new Font(family, emSize, FontStyle.Bold);
}
private static string ResolveFamilyOrGenericMono(string[] stack)
{
for (int num = stack.Length - 1; num >= 0; num--)
{
if (IsInstalled(stack[num]))
{
return stack[num];
}
}
return FontFamily.GenericMonospace.Name;
}
private static string SemiboldFamilyFor(string family)
{
string text = family + " Semibold";
if (!IsInstalled(text))
{
return family;
}
return text;
}
public static string ResolveFamily(string? wanted)
{
if (string.IsNullOrWhiteSpace(wanted))
{
return Theme.DefaultTypeface;
}
if (IsInstalled(wanted))
{
return wanted;
}
if (IsInstalled(Theme.DefaultTypeface))
{
return Theme.DefaultTypeface;
}
return FontFamily.GenericSansSerif.Name;
}
private static bool IsInstalled(string family)
{
try
{
using FontFamily fontFamily = new FontFamily(family);
return string.Equals(fontFamily.Name, family, StringComparison.OrdinalIgnoreCase);
}
catch (ArgumentException)
{
return false;
}
}
public static void Rebuild()
{
Array.Clear(_cache);
_semiboldFamily = null;
_monoFamily = null;
}
}
+161
View File
@@ -0,0 +1,161 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Forms;
namespace VibranceHud.Design;
public sealed class HoverFade
{
private static class Ticker
{
private static readonly List<HoverFade> Active = new List<HoverFade>();
private static Timer? _timer;
public static void Enrol(HoverFade fade)
{
if (!Active.Contains(fade))
{
Active.Add(fade);
}
if (_timer == null)
{
_timer = new Timer
{
Interval = 16
};
_timer.Tick += (object? _, EventArgs _) =>
{
Tick();
};
}
_timer.Start();
}
private static void Tick()
{
for (int num = Active.Count - 1; num >= 0; num--)
{
if (!Active[num].Step())
{
Active.RemoveAt(num);
}
}
if (Active.Count == 0)
{
_timer?.Stop();
}
}
}
internal const int DurationMs = 83;
private static readonly Stopwatch Clock = Stopwatch.StartNew();
internal static Func<double> NowMs = () => Clock.Elapsed.TotalMilliseconds;
internal static Func<bool> MotionAllowed = () => SystemInformation.UIEffectsEnabled;
private readonly Control _owner;
private float _value;
private float _from;
private float _target;
private double _startMs;
public float Value
{
get
{
if (_value == _target)
{
return _value;
}
double num = (NowMs() - _startMs) / 83.0;
if (num >= 1.0)
{
_value = _target;
return _value;
}
_value = _from + (_target - _from) * (float)StandardEase(num);
return _value;
}
}
internal static double StandardEase(double x)
{
if (x <= 0.0)
{
return 0.0;
}
if (x >= 1.0)
{
return 1.0;
}
double num = 0.0;
double num2 = 1.0;
double num3 = x;
for (int i = 0; i < 40; i++)
{
num3 = (num + num2) / 2.0;
if (B(num3, 0.33, 0.67) < x)
{
num = num3;
}
else
{
num2 = num3;
}
}
return B(num3, 0.0, 1.0);
static double B(double t, double p1, double p2)
{
return 3.0 * (1.0 - t) * (1.0 - t) * t * p1 + 3.0 * (1.0 - t) * t * t * p2 + t * t * t;
}
}
public HoverFade(Control owner)
{
_owner = owner;
}
public void Set(bool hot)
{
float num = (hot ? 1f : 0f);
if (_target == num)
{
return;
}
if (!MotionAllowed())
{
Snap(hot);
return;
}
_from = Value;
_startMs = NowMs();
_target = num;
if (_value != _target)
{
Ticker.Enrol(this);
}
}
public void Snap(bool hot)
{
_target = (_value = (_from = (hot ? 1f : 0f)));
}
private bool Step()
{
if (_owner.IsDisposed)
{
return false;
}
_owner.Invalidate();
return _value != _target;
}
}
+14
View File
@@ -0,0 +1,14 @@
using System.Drawing;
namespace VibranceHud.Design;
public interface IBackdrop
{
bool Moves { get; }
void Resize(int w, int h);
void Update(double dtSeconds);
void Paint(Graphics g, int offsetX, int offsetY);
}
+8
View File
@@ -0,0 +1,8 @@
namespace VibranceHud.Design;
public static class Metrics
{
public const int ButtonHeight = 32;
public const int CompactButtonHeight = 28;
}
+20
View File
@@ -0,0 +1,20 @@
using System.Drawing;
namespace VibranceHud.Design;
public sealed class OffBackdrop : IBackdrop
{
public bool Moves => false;
public void Resize(int w, int h)
{
}
public void Update(double dtSeconds)
{
}
public void Paint(Graphics g, int offsetX, int offsetY)
{
}
}
+50
View File
@@ -0,0 +1,50 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace VibranceHud.Design;
internal static class PaintGuard
{
private static readonly ConditionalWeakTable<object, object> _logged = new ConditionalWeakTable<object, object>();
private static readonly object _mark = new object();
private static readonly object _gate = new object();
internal static int LoggedForTest { get; private set; }
public static bool IsGdiFailure(Exception ex)
{
if (!(ex is OutOfMemoryException) && !(ex is ExternalException) && !(ex is ArgumentException))
{
return ex is InvalidOperationException;
}
return true;
}
public static void Try(object surfaceKey, Action paint)
{
try
{
paint();
}
catch (Exception ex) when (IsGdiFailure(ex))
{
LogOnce(surfaceKey, ex);
}
}
public static void LogOnce(object surfaceKey, Exception ex)
{
lock (_gate)
{
if (!_logged.TryAdd(surfaceKey, _mark))
{
return;
}
LoggedForTest++;
}
CrashLog.Write(ex);
}
}
+58
View File
@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Drawing;
namespace VibranceHud.Design;
public static class Readability
{
public const double AA = 4.5;
public const double BrightestFraction = 0.05;
public static double RelativeLuminance(Color c)
{
return 0.2126 * Channel(c.R) + 0.7152 * Channel(c.G) + 0.0722 * Channel(c.B);
}
private static double Channel(int v)
{
double num = (double)v / 255.0;
if (!(num <= 0.04045))
{
return Math.Pow((num + 0.055) / 1.055, 2.4);
}
return num / 12.92;
}
public static double Contrast(Color a, Color b)
{
double val = RelativeLuminance(a);
double val2 = RelativeLuminance(b);
double num = Math.Max(val, val2);
double num2 = Math.Min(val, val2);
return (num + 0.05) / (num2 + 0.05);
}
public static Color Over(Color overlay, int alpha, Color ground)
{
int num = Math.Clamp(alpha, 0, 255);
return Color.FromArgb(255, ground.R + num * (overlay.R - ground.R) / 255, ground.G + num * (overlay.G - ground.G) / 255, ground.B + num * (overlay.B - ground.B) / 255);
}
public static Color BrightestFivePercent(IReadOnlyList<Color> pixels)
{
if (pixels == null || pixels.Count == 0)
{
return Color.Black;
}
List<(double, Color)> list = new List<(double, Color)>(pixels.Count);
foreach (Color pixel in pixels)
{
list.Add((RelativeLuminance(pixel), pixel));
}
list.Sort(((double L, Color C) x, (double L, Color C) y) => x.L.CompareTo(y.L));
int value = (int)Math.Floor(0.95 * (double)(list.Count - 1));
return list[Math.Clamp(value, 0, list.Count - 1)].Item2;
}
}
+418
View File
@@ -0,0 +1,418 @@
using System.Drawing;
namespace VibranceHud.Design;
public static class SignalTokens
{
public static class Root
{
public static readonly Color Signal1 = Color.FromArgb(255, 252, 71, 56);
public static readonly Color Signal1Paper = Color.FromArgb(255, 200, 38, 26);
public static readonly Color Signal2 = Color.FromArgb(255, 253, 147, 32);
public static readonly Color Signal2Paper = Color.FromArgb(255, 184, 90, 0);
public static readonly Color Signal3 = Color.FromArgb(255, 250, 223, 39);
public static readonly Color Signal3Paper = Color.FromArgb(255, 138, 122, 0);
public static readonly Color Signal4 = Color.FromArgb(255, 89, 222, 101);
public static readonly Color Signal4Paper = Color.FromArgb(255, 30, 138, 58);
public static readonly Color Signal5 = Color.FromArgb(255, 54, 220, 236);
public static readonly Color Signal5Paper = Color.FromArgb(255, 0, 127, 140);
public static readonly Color Signal6 = Color.FromArgb(255, 55, 137, 253);
public static readonly Color Signal6Paper = Color.FromArgb(255, 31, 99, 214);
public static readonly Color SignalStart = Color.FromArgb(255, 255, 255, 255);
public static readonly Color SuccessPaper = Color.FromArgb(255, 5, 119, 59);
public static readonly Color WarningPaper = Color.FromArgb(255, 159, 92, 12);
public static readonly Color DangerPaper = Color.FromArgb(255, 197, 44, 42);
public static readonly Color InfoPaper = Color.FromArgb(255, 13, 106, 187);
public static readonly Color XBefore = Color.FromArgb(255, 255, 59, 48);
public static readonly Color XAfter = Color.FromArgb(255, 34, 197, 94);
public static readonly Color XHook = Color.FromArgb(255, 255, 230, 0);
public static readonly Color XDiscord = Color.FromArgb(255, 88, 101, 242);
public static readonly Color PPaper = Color.FromArgb(255, 255, 255, 255);
public static readonly Color PPaper2 = Color.FromArgb(255, 243, 243, 243);
public static readonly Color PPaperRule = Color.FromArgb(255, 222, 222, 222);
public static readonly Color PInk = Color.FromArgb(255, 17, 17, 20);
public static readonly Color PInk2 = Color.FromArgb(255, 85, 85, 85);
public static readonly Color PInk3 = Color.FromArgb(255, 108, 108, 108);
public static readonly Color BrandGround = Color.FromArgb(255, 21, 21, 21);
public static readonly Color BrandInk = Color.FromArgb(255, 255, 255, 255);
public const string GlassFill = "color-mix(in srgb, #151515 58%, transparent)";
public const string GlassFillFallback = "color-mix(in srgb, #151515 94%, transparent)";
public const int GlassBlur = 22;
public static readonly Color GlassHairline = Color.FromArgb(20, 255, 255, 255);
public const string FontDisplayStack = "\"Sofia Sans Extra Condensed\", \"Arial Narrow\", sans-serif";
public static readonly string[] FontDisplayFamilies = new string[2] { "Sofia Sans Extra Condensed", "Arial Narrow" };
public const string FontTextStack = "\"Host Grotesk\", \"Segoe UI\", system-ui, sans-serif";
public static readonly string[] FontTextFamilies = new string[2] { "Host Grotesk", "Segoe UI" };
public const string FontUiStack = "\"Segoe UI Variable Text\", \"Segoe UI\", system-ui, sans-serif";
public static readonly string[] FontUiFamilies = new string[2] { "Segoe UI Variable Text", "Segoe UI" };
public const string FontMonoStack = "\"Cascadia Mono\", Consolas, ui-monospace, monospace";
public static readonly string[] FontMonoFamilies = new string[2] { "Cascadia Mono", "Consolas" };
public const int AppCaptionWeight = 400;
public const int AppCaptionSizePx = 12;
public const int AppCaptionLinePx = 16;
public const int AppCaptionStrongWeight = 600;
public const int AppCaptionStrongSizePx = 12;
public const int AppCaptionStrongLinePx = 16;
public const int AppBodyWeight = 400;
public const int AppBodySizePx = 14;
public const int AppBodyLinePx = 20;
public const int AppBodyStrongWeight = 600;
public const int AppBodyStrongSizePx = 14;
public const int AppBodyStrongLinePx = 20;
public const int AppSubtitleWeight = 600;
public const int AppSubtitleSizePx = 20;
public const int AppSubtitleLinePx = 28;
public const int AppTitleWeight = 600;
public const int AppTitleSizePx = 28;
public const int AppTitleLinePx = 36;
public const int AppValueWeight = 600;
public const int AppValueSizePx = 40;
public const int AppValueLinePx = 48;
public const string WebDisplayXl = "800 144px/0.88 \"Sofia Sans Extra Condensed\", \"Arial Narrow\", sans-serif";
public const string WebDisplayL = "800 88px/0.9 \"Sofia Sans Extra Condensed\", \"Arial Narrow\", sans-serif";
public const string WebDisplayM = "800 48px/0.95 \"Sofia Sans Extra Condensed\", \"Arial Narrow\", sans-serif";
public const string WebHeading = "600 28px/1.2 \"Host Grotesk\", \"Segoe UI\", system-ui, sans-serif";
public const string WebSubheading = "600 20px/1.3 \"Host Grotesk\", \"Segoe UI\", system-ui, sans-serif";
public const string WebMenu = "500 18px/1.3 \"Host Grotesk\", \"Segoe UI\", system-ui, sans-serif";
public const string WebBodyL = "400 18px/1.55 \"Host Grotesk\", \"Segoe UI\", system-ui, sans-serif";
public const string WebBody = "400 16px/1.55 \"Host Grotesk\", \"Segoe UI\", system-ui, sans-serif";
public const string WebSmall = "400 14px/1.45 \"Host Grotesk\", \"Segoe UI\", system-ui, sans-serif";
public const string WebLabelL = "500 14px/1.3 \"Host Grotesk\", \"Segoe UI\", system-ui, sans-serif";
public const string WebLabel = "500 13px/1.3 \"Host Grotesk\", \"Segoe UI\", system-ui, sans-serif";
public const string WebCode = "400 13px/1.5 \"Cascadia Mono\", Consolas, ui-monospace, monospace";
public const string TrackDisplay = "-0.01em";
public const string TrackWordmark = "-0.012em";
public const int Space0 = 0;
public const int Space1 = 2;
public const int Space2 = 4;
public const int Space3 = 8;
public const int Space4 = 12;
public const int Space5 = 16;
public const int Space6 = 20;
public const int Space7 = 24;
public const int Space8 = 32;
public const int Space9 = 40;
public const int Space10 = 48;
public const int Space11 = 64;
public const int Space12 = 80;
public const int Space13 = 96;
public const int Space14 = 128;
public const int Radius0 = 0;
public const int Radius4 = 4;
public const int Radius8 = 8;
public const int RadiusPill = 999;
public const int StrokeHairline = 1;
public const float StrokeIcon = 1.5f;
public const int StrokeFocus = 2;
public const int FocusGap = 2;
public const int SignalStrand = 1;
public const int DurInstantMs = 0;
public const int DurFadeMs = 83;
public const int DurMoveMs = 167;
public const int DurSplashMs = 900;
public const string EaseStandard = "cubic-bezier(0.33, 0, 0.67, 1)";
public const string EaseEnter = "cubic-bezier(0, 0, 0, 1)";
}
public static class Ash
{
public static readonly Color Bg = Color.FromArgb(255, 21, 21, 21);
public static readonly Color Surface1 = Color.FromArgb(255, 28, 28, 28);
public static readonly Color Surface2 = Color.FromArgb(255, 35, 35, 35);
public static readonly Color Surface3 = Color.FromArgb(255, 42, 42, 42);
public static readonly Color Hover = Color.FromArgb(255, 49, 49, 49);
public static readonly Color Pressed = Color.FromArgb(255, 57, 57, 57);
public static readonly Color Border = Color.FromArgb(255, 51, 51, 51);
public static readonly Color WindowEdge = Color.FromArgb(255, 69, 69, 69);
public static readonly Color Text1 = Color.FromArgb(255, 243, 243, 243);
public static readonly Color Text2 = Color.FromArgb(255, 193, 193, 193);
public static readonly Color TextDisabled = Color.FromArgb(255, 88, 88, 88);
public static readonly Color Track = Color.FromArgb(255, 61, 61, 61);
public static readonly Color Accent = Color.FromArgb(255, 255, 255, 255);
public static readonly Color AccentHover = Color.FromArgb(255, 222, 222, 222);
public static readonly Color AccentPressed = Color.FromArgb(255, 196, 196, 196);
public static readonly Color OnAccent = Color.FromArgb(255, 21, 21, 21);
public static readonly Color Focus = Color.FromArgb(255, 255, 255, 255);
public static readonly Color PreviewWell = Color.FromArgb(255, 28, 28, 28);
public static readonly Color Text3 = Color.FromArgb(255, 153, 153, 153);
public static readonly Color BorderStrong = Color.FromArgb(255, 116, 116, 116);
public static readonly Color Success = Color.FromArgb(255, 94, 206, 131);
public static readonly Color Warning = Color.FromArgb(255, 233, 175, 45);
public static readonly Color Danger = Color.FromArgb(255, 255, 158, 147);
public static readonly Color Info = Color.FromArgb(255, 127, 190, 243);
public static readonly Color Chrome = Color.FromArgb(255, 21, 21, 21);
public static readonly Color Overlay = Color.FromArgb(255, 42, 42, 42);
public static readonly Color KnobRing = Color.FromArgb(255, 28, 28, 28);
public static readonly Color SelectedSuffix = Color.FromArgb(255, 85, 85, 85);
public static readonly Color TextOnFill = Color.FromArgb(255, 193, 193, 193);
public static readonly Color FieldFill = Color.FromArgb(0, 0, 0, 0);
public static readonly Color Selection = Color.FromArgb(255, 255, 255, 255);
public static readonly Color SignalTrack = Color.FromArgb(255, 61, 61, 61);
}
public static class Slate
{
public const double GuiOpacity = 0.66;
public static readonly Color SlateBase = Color.FromArgb(255, 15, 18, 22);
public static readonly Color Bg = Color.FromArgb(255, 15, 18, 22);
public static readonly Color ChromeDefault = Color.FromArgb(189, 15, 18, 22);
public static readonly Color Surface1Default = Color.FromArgb(168, 15, 18, 22);
public static readonly Color Surface2 = Color.FromArgb(18, 255, 255, 255);
public static readonly Color Surface3 = Color.FromArgb(242, 15, 18, 22);
public static readonly Color Overlay = Color.FromArgb(242, 15, 18, 22);
public static readonly Color Hover = Color.FromArgb(26, 255, 255, 255);
public static readonly Color Pressed = Color.FromArgb(36, 255, 255, 255);
public static readonly Color Border = Color.FromArgb(20, 255, 255, 255);
public static readonly Color BorderStrong = Color.FromArgb(128, 255, 255, 255);
public static readonly Color WindowEdge = Color.FromArgb(36, 255, 255, 255);
public static readonly Color Track = Color.FromArgb(56, 255, 255, 255);
public static readonly Color Text1 = Color.FromArgb(255, 243, 245, 248);
public static readonly Color Text2 = Color.FromArgb(255, 210, 214, 220);
public static readonly Color Text3 = Color.FromArgb(255, 195, 200, 207);
public static readonly Color TextDisabled = Color.FromArgb(97, 255, 255, 255);
public static readonly Color TextOnFill = Color.FromArgb(255, 243, 245, 248);
public static readonly Color Accent = Color.FromArgb(255, 255, 255, 255);
public static readonly Color AccentHover = Color.FromArgb(255, 222, 222, 222);
public static readonly Color AccentPressed = Color.FromArgb(255, 196, 196, 196);
public static readonly Color OnAccent = Color.FromArgb(255, 21, 21, 21);
public static readonly Color Focus = Color.FromArgb(255, 255, 255, 255);
public static readonly Color PreviewWell = Color.FromArgb(255, 28, 28, 28);
public static readonly Color Success = Color.FromArgb(255, 94, 206, 131);
public static readonly Color Warning = Color.FromArgb(255, 233, 175, 45);
public static readonly Color Danger = Color.FromArgb(255, 255, 158, 147);
public static readonly Color Info = Color.FromArgb(255, 127, 190, 243);
public static readonly Color KnobRing = Color.FromArgb(255, 15, 18, 22);
public static readonly Color FieldFill = Color.FromArgb(255, 15, 18, 22);
public static readonly Color SelectedSuffix = Color.FromArgb(255, 85, 85, 85);
public static readonly Color Selection = Color.FromArgb(255, 255, 255, 255);
public static readonly Color SignalTrack = Color.FromArgb(56, 255, 255, 255);
public const int MatteBlur = 16;
public const int Gutter = 16;
}
public static class Paper
{
public static readonly Color Bg = Color.FromArgb(255, 255, 255, 255);
public static readonly Color Surface1 = Color.FromArgb(255, 243, 243, 243);
public static readonly Color Surface2 = Color.FromArgb(255, 243, 243, 243);
public static readonly Color Surface3 = Color.FromArgb(255, 255, 255, 255);
public static readonly Color Border = Color.FromArgb(255, 222, 222, 222);
public static readonly Color BorderStrong = Color.FromArgb(255, 128, 128, 128);
public static readonly Color Text1 = Color.FromArgb(255, 17, 17, 20);
public static readonly Color Text2 = Color.FromArgb(255, 85, 85, 85);
public static readonly Color Text3 = Color.FromArgb(255, 108, 108, 108);
public static readonly Color Accent = Color.FromArgb(255, 17, 17, 20);
public static readonly Color OnAccent = Color.FromArgb(255, 255, 255, 255);
public static readonly Color Focus = Color.FromArgb(255, 17, 17, 20);
public static readonly Color PreviewWell = Color.FromArgb(255, 243, 243, 243);
public static readonly Color Success = Color.FromArgb(255, 5, 119, 59);
public static readonly Color Warning = Color.FromArgb(255, 159, 92, 12);
public static readonly Color Danger = Color.FromArgb(255, 197, 44, 42);
public static readonly Color Info = Color.FromArgb(255, 13, 106, 187);
public static readonly Color Signal1 = Color.FromArgb(255, 200, 38, 26);
public static readonly Color Signal2 = Color.FromArgb(255, 184, 90, 0);
public static readonly Color Signal3 = Color.FromArgb(255, 138, 122, 0);
public static readonly Color Signal4 = Color.FromArgb(255, 30, 138, 58);
public static readonly Color Signal5 = Color.FromArgb(255, 0, 127, 140);
public static readonly Color Signal6 = Color.FromArgb(255, 31, 99, 214);
public static readonly Color SignalStart = Color.FromArgb(255, 17, 17, 20);
}
public const string SourceFile = "Design/tokens/tokens.css";
public const string SourceSha256 = "77EEB2F61406247D6315CE64314C7CA56409F413EDF19BC5F921C7FE5F1813D3";
}
+3
View File
@@ -0,0 +1,3 @@
namespace VibranceHud.Design;
public readonly record struct SignatureLook(string Theme, BackdropLook Backdrop, SurfaceStyle Surface, Chrome Chrome = Chrome.Plexus);
+27
View File
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
namespace VibranceHud.Design;
public static class SignatureLooks
{
public static readonly IReadOnlyList<SignatureLook> All = new SignatureLook[2]
{
new SignatureLook("Ash", BackdropLook.Off, SurfaceStyle.Glass),
new SignatureLook("Slate", BackdropLook.Off, SurfaceStyle.Glass)
};
public static bool TryGet(string? theme, out SignatureLook look)
{
foreach (SignatureLook item in All)
{
if (string.Equals(item.Theme, theme, StringComparison.OrdinalIgnoreCase))
{
look = item;
return true;
}
}
look = default;
return false;
}
}
+54
View File
@@ -0,0 +1,54 @@
using System;
using System.Drawing;
namespace VibranceHud.Design;
public static class SlateSurface
{
public const double MinOpacity = 0.45;
public const double MaxOpacity = 0.85;
public const double ChromeCeiling = 0.95;
public const double ChromeBoost = 0.08;
private static double _userOpacity = 0.66;
public static double UserOpacity
{
get
{
return _userOpacity;
}
set
{
_userOpacity = Math.Clamp(value, 0.45, 0.85);
}
}
public static bool MatteBlur { get; set; } = true;
public static bool Active => Theme.IsSeeThrough;
public static Color Base => SignalTokens.Slate.SlateBase;
public static double PanelOpacity => Math.Clamp(_userOpacity, 0.45, 0.85);
public static double ChromeOpacity => Math.Min(0.95, PanelOpacity + 0.08);
public static int PanelAlpha => Alpha(PanelOpacity);
public static int ChromeAlpha => Alpha(ChromeOpacity);
internal static int Alpha(double opacity)
{
return (int)Math.Round(Math.Clamp(opacity, 0.0, 1.0) * 255.0);
}
internal static void ResetForTests()
{
_userOpacity = 0.66;
MatteBlur = true;
}
}
+142
View File
@@ -0,0 +1,142 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using VibranceHud.Theming;
namespace VibranceHud.Design;
public sealed class SoftBackdrop : IBackdrop
{
private int _w;
private int _h;
private const int MostLayers = 4;
private readonly List<(string Key, Bitmap Layer)> _layers = new List<(string, Bitmap)>();
private readonly HashSet<string> _failedKeys = new HashSet<string>();
internal int LayerBuilds { get; private set; }
internal int PoolDrawsForTest { get; private set; }
internal int LayersHeldForTest => _layers.Count;
public bool Moves => false;
public void Resize(int w, int h)
{
if (w != _w || h != _h)
{
foreach (var layer in _layers)
{
layer.Layer.Dispose();
}
_layers.Clear();
_failedKeys.Clear();
}
_w = w;
_h = h;
}
public void Update(double dtSeconds)
{
}
public void Paint(Graphics g, int offsetX, int offsetY)
{
if (_w > 0 && _h > 0)
{
Bitmap bitmap = LayerFor(offsetX, offsetY, null);
if (bitmap != null)
{
g.DrawImageUnscaled(bitmap, 0, 0);
}
}
}
internal void PaintOver(BlossomBough under, Graphics g, int offsetX, int offsetY)
{
if (_w <= 0 || _h <= 0)
{
under.Paint(g, offsetX, offsetY);
return;
}
Bitmap bitmap = LayerFor(offsetX, offsetY, under);
if (bitmap != null)
{
g.DrawImageUnscaled(bitmap, 0, 0);
}
}
private Bitmap? LayerFor(int offsetX, int offsetY, BlossomBough? under)
{
string text = Theme.CurrentName + "|" + _w + "x" + _h + "|" + offsetX + "," + offsetY + ((under == null) ? "" : (AppBackground.IsSet ? "|tree|img" : "|tree"));
for (int i = 0; i < _layers.Count; i++)
{
if (_layers[i].Key == text)
{
return _layers[i].Layer;
}
}
if (_failedKeys.Contains(text))
{
return null;
}
if (_layers.Count >= 4)
{
_layers[0].Layer.Dispose();
_layers.RemoveAt(0);
}
Bitmap bitmap = null;
try
{
BackdropLooks.FailPointForTest?.Invoke("build");
bitmap = new Bitmap(_w, _h, PixelFormat.Format32bppPArgb);
using Graphics graphics = Graphics.FromImage(bitmap);
graphics.Clear(Color.Transparent);
under?.Paint(graphics, offsetX, offsetY);
DrawPools(graphics, offsetX, offsetY);
}
catch (Exception ex) when (PaintGuard.IsGdiFailure(ex))
{
bitmap?.Dispose();
if (_failedKeys.Count >= 16)
{
_failedKeys.Clear();
}
_failedKeys.Add(text);
PaintGuard.LogOnce(this, ex);
return null;
}
LayerBuilds++;
_layers.Add((text, bitmap));
return bitmap;
}
private void DrawPools(Graphics g, int offsetX, int offsetY)
{
PoolDrawsForTest++;
Pool(g, Theme.PlexusNodeA, offsetX + (int)((float)_w * 0.22f), offsetY + (int)((float)_h * 0.18f), (int)((float)Math.Max(_w, _h) * 0.55f));
Pool(g, Theme.PlexusNodeB, offsetX + (int)((float)_w * 0.8f), offsetY + (int)((float)_h * 0.72f), (int)((float)Math.Max(_w, _h) * 0.45f));
}
private static void Pool(Graphics g, Color colour, int cx, int cy, int radius)
{
if (radius <= 0)
{
return;
}
Rectangle rect = new Rectangle(cx - radius, cy - radius, radius * 2, radius * 2);
using GraphicsPath graphicsPath = new GraphicsPath();
graphicsPath.AddEllipse(rect);
PathGradientBrush pathGradientBrush = new PathGradientBrush(graphicsPath);
pathGradientBrush.CenterColor = Color.FromArgb(46, colour);
pathGradientBrush.SurroundColors = new Color[1] { Color.FromArgb(0, colour) };
using PathGradientBrush brush = pathGradientBrush;
g.FillEllipse(brush, rect);
}
}
+7
View File
@@ -0,0 +1,7 @@
namespace VibranceHud.Design;
public enum SurfaceStyle
{
Glass,
Flat
}
+29
View File
@@ -0,0 +1,29 @@
using System;
namespace VibranceHud.Design;
public static class SurfaceStyles
{
public static string Name(SurfaceStyle style)
{
return style.ToString();
}
public static SurfaceStyle Parse(string? stored)
{
string text = (stored ?? "").Trim();
if (text.Length == 0 || char.IsDigit(text[0]) || text[0] == '-')
{
return SurfaceStyle.Glass;
}
if (text.Contains(','))
{
return SurfaceStyle.Glass;
}
if (!Enum.TryParse<SurfaceStyle>(text, ignoreCase: true, out var result) || !Enum.IsDefined(result))
{
return SurfaceStyle.Glass;
}
return result;
}
}
+81
View File
@@ -0,0 +1,81 @@
using System.Drawing;
namespace VibranceHud.Design;
public sealed class SwitchableBackdrop : IBackdrop
{
private readonly BlossomBough _bough = new BlossomBough();
private IBackdrop? _layer;
private SoftBackdrop? _soft;
private bool _boughShows = true;
private int _w;
private int _h;
public BackdropLook Look { get; private set; }
public bool Moves
{
get
{
if (!_boughShows || !_bough.Moves)
{
return _layer?.Moves ?? false;
}
return true;
}
}
internal SoftBackdrop? SoftForTest => _layer as SoftBackdrop;
public void Use(BackdropLook look)
{
if (look != Look)
{
Look = look;
_boughShows = look != BackdropLook.Off;
SoftBackdrop layer = ((look != BackdropLook.Soft) ? null : (_soft ?? (_soft = new SoftBackdrop())));
_layer = layer;
if (_w > 0 && _h > 0)
{
_layer?.Resize(_w, _h);
}
}
}
public void Resize(int w, int h)
{
_w = w;
_h = h;
_bough.Resize(w, h);
_soft?.Resize(w, h);
if (_layer != _soft)
{
_layer?.Resize(w, h);
}
}
public void Update(double dtSeconds)
{
_bough.Update(dtSeconds);
_layer?.Update(dtSeconds);
}
public void Paint(Graphics g, int offsetX, int offsetY)
{
if (_boughShows && _layer is SoftBackdrop softBackdrop)
{
softBackdrop.PaintOver(_bough, g, offsetX, offsetY);
return;
}
if (_boughShows)
{
_bough.Paint(g, offsetX, offsetY);
}
_layer?.Paint(g, offsetX, offsetY);
}
}
+58
View File
@@ -0,0 +1,58 @@
using System;
namespace VibranceHud.Design;
public static class Tokens
{
public const int BaseDpi = 96;
public const int XXS = 2;
public const int XS = 4;
public const int S = 8;
public const int M = 12;
public const int L = 16;
public const int L2 = 20;
public const int XL = 24;
public const int XXL = 32;
public const int XXXXL = 40;
public const int XXXL = 48;
public static int Dpi { get; set; } = 96;
public static int Scale(int logical)
{
return ScaleAt(Dpi, logical);
}
public static int ScaleAt(int dpi, int logical)
{
if (logical == 0)
{
return 0;
}
if (dpi <= 0)
{
dpi = 96;
}
int val = (int)Math.Round((double)logical * ((double)dpi / 96.0), MidpointRounding.AwayFromZero);
if (logical <= 0)
{
return Math.Min(-1, val);
}
return Math.Max(1, val);
}
public static float ScaleF(float logical)
{
return logical * ((float)Dpi / 96f);
}
}
+3
View File
@@ -0,0 +1,3 @@
namespace VibranceHud.Design;
public readonly record struct TypeStep(int SizePx, int LinePx, int Weight);