CustomSkinEditor - Change highlight color on texture

This commit is contained in:
miku-666
2024-08-15 18:09:00 +02:00
parent c92bb8ed2d
commit 3e205bdce5
2 changed files with 9 additions and 2 deletions

View File

@@ -19,6 +19,12 @@ namespace PckStudio.Extensions
return Color.FromArgb(color.A, 255 - color.R, 255 - color.G, 255 - color.B);
}
internal static Color GreyScaled(this Color color)
{
int greyScaleValue = (color.R + color.G + color.B) / 3;
return Color.FromArgb(color.A, greyScaleValue, greyScaleValue, greyScaleValue);
}
internal static int ToBGR(this Color color)
{
return color.B << 16 | color.G << 8 | color.R;

View File

@@ -289,7 +289,8 @@ namespace PckStudio.Forms.Editor
g.DrawImage(uvArea, new Rectangle(0, 0, 1, 1));
}
renderer3D1.HighlightlingColor = refImg.GetPixel(0, 0).Inversed();
Color avgColor = refImg.GetPixel(0, 0);
renderer3D1.HighlightlingColor = avgColor.Inversed();
Size scaleSize = new Size(_skin.Model.Texture.Width * scale, _skin.Model.Texture.Height * scale);
uvPictureBox.Image = new Bitmap(scaleSize.Width, scaleSize.Height);
@@ -297,7 +298,7 @@ namespace PckStudio.Forms.Editor
{
float lineWidth = ((_skin.Model.Texture.Width / renderer3D1.TextureSize.Width) + (_skin.Model.Texture.Height / renderer3D1.TextureSize.Height)) / 2f;
GraphicsPath graphicsPath = box.GetUVGraphicsPath(new System.Numerics.Vector2(scaleSize.Width * renderer3D1.TillingFactor.X, scaleSize.Height * renderer3D1.TillingFactor.Y));
var brush = new SolidBrush(Color.FromArgb(127, renderer3D1.HighlightlingColor));
var brush = new SolidBrush(Color.FromArgb(127, avgColor.GreyScaled()));
g.ApplyConfig(_graphicsConfig);
g.DrawImage(_skin.Model.Texture, new Rectangle(Point.Empty, scaleSize), new Rectangle(Point.Empty, _skin.Model.Texture.Size), GraphicsUnit.Pixel);
g.FillPath(brush, graphicsPath);