From ce5db33bd2e405b78537725b0ed70e5227dba25a Mon Sep 17 00:00:00 2001 From: Mark Date: Sat, 27 Apr 2019 15:46:24 -0400 Subject: [PATCH] Color correction + line spacing fixes --- TwitchChatVideo/ChatHandler.cs | 8 ++++---- TwitchChatVideo/Colors.cs | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/TwitchChatVideo/ChatHandler.cs b/TwitchChatVideo/ChatHandler.cs index 6406354..6a62647 100644 --- a/TwitchChatVideo/ChatHandler.cs +++ b/TwitchChatVideo/ChatHandler.cs @@ -31,7 +31,7 @@ public class ChatHandler : IDisposable public class Line { - + private const int MinimumLineHeight = 20; public float OffsetX { get; } public float OffsetY { get; } public List Drawables { get; } @@ -40,7 +40,7 @@ public class Line public Line(float x, float y, float height, List dl) { - Height = height; + Height = Math.Min(height, MinimumLineHeight); OffsetX = x; OffsetY = y; Drawables = dl; @@ -253,7 +253,7 @@ public DrawableMessage MakeDrawableMessage(ChatMessage message) Action new_line = delegate { y += maximum_y_offset; - var line = new Line(ChatVideo.HorizontalPad, y, Font.Height + 2 * maximum_y_offset, dl); + var line = new Line(ChatVideo.HorizontalPad, y, Font.Height + maximum_y_offset, dl); lines.Add(line); y += maximum_y_offset + line.Height; maximum_y_offset = 0; @@ -363,7 +363,7 @@ public DrawableMessage MakeDrawableMessage(ChatMessage message) if(dl.Count > 0) { - lines.Add(new Line(ChatVideo.HorizontalPad, y + maximum_y_offset, Font.Height + 2 * maximum_y_offset, dl)); + lines.Add(new Line(ChatVideo.HorizontalPad, y + maximum_y_offset, Font.Height + maximum_y_offset, dl)); } return new DrawableMessage { diff --git a/TwitchChatVideo/Colors.cs b/TwitchChatVideo/Colors.cs index 87cea3d..b18ff53 100644 --- a/TwitchChatVideo/Colors.cs +++ b/TwitchChatVideo/Colors.cs @@ -108,17 +108,24 @@ public static Color GetCorrected(Color color, Color background, string name) if(darkMode) { - var dark_lum = Math.Max(hsl.L, .5); - if(dark_lum < .6 && hsl.H > 196 && hsl.H < 300) + hsl.L = Math.Max(hsl.L, .5); + if(hsl.L < .6 && hsl.H > 196 && hsl.H < 300) { hsl.L += Math.Sin((hsl.H - 196) / (300 - 196) * Math.PI) * hsl.S * .4; } - return cache[name] = HSL.ToRGB(hsl); + if (hsl.L < 0.8f && (hsl.H < 22 || hsl.H > 331)) + { + hsl.L += (hsl.S * .1); + } + } + else + { + hsl.S = Math.Min(.4, hsl.S); + hsl.L = Math.Min(.5, hsl.L); } - hsl.S = Math.Min(.4, hsl.S); - hsl.L = Math.Min(.5, hsl.L); + hsl.L = Math.Min(.95, hsl.L); return cache[name] = HSL.ToRGB(hsl); }