Skip to content

Commit

Permalink
Color correction + line spacing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cairthenn committed Apr 27, 2019
1 parent 9343ec6 commit ce5db33
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
8 changes: 4 additions & 4 deletions TwitchChatVideo/ChatHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Drawable> Drawables { get; }
Expand All @@ -40,7 +40,7 @@ public class Line

public Line(float x, float y, float height, List<Drawable> dl)
{
Height = height;
Height = Math.Min(height, MinimumLineHeight);
OffsetX = x;
OffsetY = y;
Drawables = dl;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
17 changes: 12 additions & 5 deletions TwitchChatVideo/Colors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit ce5db33

Please sign in to comment.