Skip to content

Commit 8bf2d86

Browse files
committed
infographic color fixes
1 parent 3857bcf commit 8bf2d86

4 files changed

Lines changed: 16 additions & 10 deletions

File tree

ARKBreedingStats/InfoGraphic/CreatureInfoGraphic.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ public static Task<Bitmap> InfoGraphicAsync(this Creature creature, CreatureColl
5353
BackgroundImageResizing = Properties.Settings.Default.InfoGraphicBackgroundSizing,
5454
widthOutlineCreature = Properties.Settings.Default.InfoGraphicCreatureOutlineWidth,
5555
creatureOutlineBlurring = Properties.Settings.Default.InfoGraphicCreatureOutlineBlurring,
56-
creatureScaling = Properties.Settings.Default.InfoGraphicCreatureScaling
56+
creatureScaling = Properties.Settings.Default.InfoGraphicCreatureScaling,
57+
ColorBasedOnCreature = Properties.Settings.Default.InfographicColorByCreature,
58+
TintBackgroundImage = Properties.Settings.Default.InfographicTintBackgroundImage
5759
});
5860

5961
/// <summary>
@@ -141,19 +143,22 @@ public static async Task<Bitmap> InfoGraphicAsync(this Creature creature, Creatu
141143
g.SmoothingMode = SmoothingMode.AntiAlias;
142144
g.TextRenderingHint = TextRenderingHint.AntiAlias;
143145

144-
145146
var backgroundImageIsDrawn = false;
146-
if (settings.backColor.A != 255)
147+
if (backColor.A != 255)
147148
{
148149
backgroundImageIsDrawn = DrawBackgroundImage(g, settings.backgroundImagePath, 0, yOffsetBox,
149150
widthBox, heightBox, settings.BackgroundImageResizing);
150151
if (settings.TintBackgroundImage)
151-
ImageTools.TintImage(bmp, Utils.ColorFromHue(colorHue, settings.backColor.GetBrightness() - .5));
152+
//ImageTools.TintImage(bmp, backColor);
153+
ImageTools.TintImage(bmp, Utils.ColorFromHsv(colorHue, settings.backColor.GetSaturation(), settings.backColor.GetValue()));
152154
}
153155

154156
var currentYPosition = borderAndPaddings[0] + yOffsetBox;
155-
using (var backgroundBrush = new SolidBrush(backColor))
157+
if (backColor.A != 0)
158+
{
159+
using var backgroundBrush = new SolidBrush(backColor);
156160
g.FillRectangle(backgroundBrush, 0, yOffsetBox, widthBox, heightBox);
161+
}
157162

158163
var headerText = creature.Species.Name(creature.sex, true, true) +
159164
(settings.displayCreatureName ? $" - {creature.name}" : string.Empty);
@@ -623,7 +628,8 @@ private static Color GetMainColor(Creature c)
623628
r => r?.name != null && r.name.Contains("body", StringComparison.InvariantCultureIgnoreCase));
624629
}
625630

626-
if (tintColorRegionId == -1) tintColorRegionId = 0;
631+
if (tintColorRegionId == -1) tintColorRegionId = Array.FindIndex(c.Species.colors, r => r?.name != null);
632+
if (tintColorRegionId == -1) return Values.V.Colors.ById(0).Color;
627633
return Values.V.Colors.ById(c.colors[tintColorRegionId]).Color;
628634
}
629635

ARKBreedingStats/InfoGraphic/InfoGraphicSettings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public class InfoGraphicSettings
3535
public int widthOutlineCreature = 0;
3636
public float creatureOutlineBlurring = 1;
3737
public float creatureScaling = 1;
38-
public bool ColorBasedOnCreature = true;
39-
public bool TintBackgroundImage = true;
38+
public bool ColorBasedOnCreature;
39+
public bool TintBackgroundImage;
4040

4141
public enum BackgroundImageResizings
4242
{

ARKBreedingStats/Utils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public static Color ColorFromHsv(double hue, double saturation = 1, double value
128128
var v = (byte)(value * 255);
129129
if (saturation < double.Epsilon)
130130
{
131-
return Color.FromArgb(v, v, v);
131+
return Color.FromArgb(alpha, v, v, v);
132132
}
133133

134134
// there are six hue sections from 0 to 360 with each having 60 degrees

ARKBreedingStats/utils/ExtensionMethods.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static void SetImageAndDisposeOld(this Button bt, Bitmap bmp)
5353
}
5454

5555
/// <summary>
56-
/// Returns the value part of this color (HSV model).
56+
/// Returns the value part of this color (HSV model) in the range 0...1.
5757
/// </summary>
5858
public static float GetValue(this Color c) => (float)Math.Max(c.R, Math.Max(c.G, c.B)) / byte.MaxValue;
5959

0 commit comments

Comments
 (0)