mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 12:33:06 +00:00
88830e0d00
Updates from net46->net7, dropping support for mono in favor of using the latest runtime (along with the performance/API improvements). Releases will be posted as 64bit only for now. Refactors a good amount of internal API methods to be more performant and more customizable for future updates & fixes. Adds functionality for Batch Editor commands to `>`, `<` and <=/>= TID/SID properties renamed to TID16/SID16 for clarity; other properties exposed for Gen7 / display variants. Main window has a new layout to account for DPI scaling (8 point grid) Fixed: Tatsugiri and Paldean Tauros now output Showdown form names as Showdown expects Changed: Gen9 species now interact based on the confirmed National Dex IDs (closes #3724) Fixed: Pokedex set all no longer clears species with unavailable non-base forms (closes #3720) Changed: Hyper Training suggestions now apply for level 50 in SV. (closes #3714) Fixed: B2/W2 hatched egg met locations exclusive to specific versions are now explicitly checked (closes #3691) Added: Properties for ribbon/mark count (closes #3659) Fixed: Traded SV eggs are now checked correctly (closes #3692)
43 lines
1.4 KiB
C#
43 lines
1.4 KiB
C#
using System;
|
|
using System.Drawing;
|
|
|
|
namespace PKHeX.Drawing;
|
|
|
|
/// <summary>
|
|
/// Utility class for manipulating <see cref="Color"/> values.
|
|
/// </summary>
|
|
public static class ColorUtil
|
|
{
|
|
private const byte MaxStat = 180; // shift the green cap down
|
|
private const byte MinStat = 0;
|
|
|
|
/// <summary>
|
|
/// Gets the <see cref="Color"/> value for the specified <see cref="stat"/> value.
|
|
/// </summary>
|
|
public static Color ColorBaseStat(int stat)
|
|
{
|
|
float x = (100f * stat) / MaxStat;
|
|
if (x > 100)
|
|
x = 100;
|
|
double red = 255f * (x > 50 ? 1 - (2 * (x - 50) / 100.0) : 1.0);
|
|
double green = 255f * (x > 50 ? 1.0 : 2 * x / 100.0);
|
|
|
|
return Blend(Color.FromArgb((int)red, (int)green, 0), Color.White, 0.4);
|
|
}
|
|
|
|
public static Color ColorBaseStatTotal(int tot)
|
|
{
|
|
const byte sumShiftDown = 175;
|
|
const float sumDivisor = 3f;
|
|
var sumToSingle = Math.Max(MinStat, tot - sumShiftDown) / sumDivisor;
|
|
return ColorBaseStat((int)sumToSingle);
|
|
}
|
|
|
|
public static Color Blend(Color color, Color backColor, double amount)
|
|
{
|
|
byte r = (byte)((color.R * amount) + (backColor.R * (1 - amount)));
|
|
byte g = (byte)((color.G * amount) + (backColor.G * (1 - amount)));
|
|
byte b = (byte)((color.B * amount) + (backColor.B * (1 - amount)));
|
|
return Color.FromArgb(r, g, b);
|
|
}
|
|
}
|