From 3e205bdce50b28561bee1bdf245acf945bec8ec0 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Thu, 15 Aug 2024 18:09:00 +0200 Subject: [PATCH] CustomSkinEditor - Change highlight color on texture --- PCK-Studio/Extensions/ColorExtensions.cs | 6 ++++++ PCK-Studio/Forms/Editor/CustomSkinEditor.cs | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/PCK-Studio/Extensions/ColorExtensions.cs b/PCK-Studio/Extensions/ColorExtensions.cs index 33ee7505..2a8a9bc5 100644 --- a/PCK-Studio/Extensions/ColorExtensions.cs +++ b/PCK-Studio/Extensions/ColorExtensions.cs @@ -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; diff --git a/PCK-Studio/Forms/Editor/CustomSkinEditor.cs b/PCK-Studio/Forms/Editor/CustomSkinEditor.cs index 12ef76c4..3944ee0e 100644 --- a/PCK-Studio/Forms/Editor/CustomSkinEditor.cs +++ b/PCK-Studio/Forms/Editor/CustomSkinEditor.cs @@ -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);