Ejemplo n.º 1
0
        public ColorScale GetPaletteScale()
        {
            var baseColorRGB        = _baseColor.ActiveColor;
            var baseColorHSL        = ColorUtils.RGBToHSL(baseColorRGB);
            var baseColorNormalized = new NormalizedRGB(baseColorRGB);

            var baseScale = new ColorScale(new Color[] { _scaleColorLight, baseColorRGB, _scaleColorDark, });

            var trimmedScale = baseScale.Trim(_clipLight, 1.0 - _clipDark);
            var trimmedLight = new NormalizedRGB(trimmedScale.GetColor(0, _interpolationMode));
            var trimmedDark  = new NormalizedRGB(trimmedScale.GetColor(1, _interpolationMode));

            var adjustedLight = trimmedLight;
            var adjustedDark  = trimmedDark;

            if (baseColorHSL.S >= _saturationAdjustmentCutoff)
            {
                adjustedLight = ColorBlending.SaturateViaLCH(adjustedLight, _saturationLight);
                adjustedDark  = ColorBlending.SaturateViaLCH(adjustedDark, _saturationDark);
            }

            if (_multiplyLight != 0)
            {
                var multiply = ColorBlending.Blend(baseColorNormalized, adjustedLight, ColorBlendMode.Multiply);
                adjustedLight = ColorUtils.InterpolateColor(adjustedLight, multiply, _multiplyLight, _interpolationMode);
            }

            if (_multiplyDark != 0)
            {
                var multiply = ColorBlending.Blend(baseColorNormalized, adjustedDark, ColorBlendMode.Multiply);
                adjustedDark = ColorUtils.InterpolateColor(adjustedDark, multiply, _multiplyDark, _interpolationMode);
            }

            if (_overlayLight != 0)
            {
                var overlay = ColorBlending.Blend(baseColorNormalized, adjustedLight, ColorBlendMode.Overlay);
                adjustedLight = ColorUtils.InterpolateColor(adjustedLight, overlay, _overlayLight, _interpolationMode);
            }

            if (_overlayDark != 0)
            {
                var overlay = ColorBlending.Blend(baseColorNormalized, adjustedDark, ColorBlendMode.Overlay);
                adjustedDark = ColorUtils.InterpolateColor(adjustedDark, overlay, _overlayDark, _interpolationMode);
            }

            var finalScale = new ColorScale(new Color[] { adjustedLight.Denormalize(), baseColorRGB, adjustedDark.Denormalize() });

            return(finalScale);
        }
Ejemplo n.º 2
0
 public static void setMaterialColorOpaque(Material m, Color c, ColorBlending colorBlending)
 {
     setMaterialColor(m, c + Color.black, colorBlending);
 }
Ejemplo n.º 3
0
        public void Start()
        {
            List <ImportedImage> imgListSFX = _imgListSFX.ToList();
            List <ImportedImage> imgList    = _imgList.ToList();

            int[] imagePerLayer = new int[] { imgList.Count, imgListSFX.Count };

            imgList.AddRange(imgListSFX);

            (int, int)maxImageSize  = (imgList.Max((x) => x.BitmapImage.Width), imgList.Max((x) => x.BitmapImage.Height));
            (int, int)maxImagePivot = (imgList.Max((x) => x.Pivot.Item1), imgList.Max((x) => x.Pivot.Item2));
            (int, int)minImagePivot = (imgList.Min((x) => x.Pivot.Item1), imgList.Min((x) => x.Pivot.Item2));

            (int, int)newSize = (
                maxImageSize.Item1 + Math.Max(Math.Abs(minImagePivot.Item1), Math.Abs(minImagePivot.Item1)),
                maxImageSize.Item2 + Math.Max(Math.Abs(maxImagePivot.Item2), Math.Abs(minImagePivot.Item2)));

            Console.WriteLine("Sprites per line: ");
            int imgPerLine = int.Parse(Console.ReadLine());

            Console.WriteLine("Squish X factor:");
            int squishXFactor = int.Parse(Console.ReadLine());

            Console.WriteLine("Squish Y factor:");
            int squishYFactor = int.Parse(Console.ReadLine());

            Console.WriteLine("Initial X Shift factor:");
            int initialXFactor = int.Parse(Console.ReadLine());

            Console.WriteLine("Initial Y Shift factor:");
            int initialYFactor = int.Parse(Console.ReadLine());

            (int, int)newBigImageSize = ((newSize.Item1 - squishXFactor + initialXFactor) * imgPerLine, (newSize.Item2 - squishYFactor) * (int)Math.Ceiling((double)imagePerLayer[0] / imgPerLine));

            Color[][] nCM1 = ImageProcessing.CreateBlankColorMatrix(newBigImageSize.Item1, newBigImageSize.Item2);
            Color[][] nCM2 = ImageProcessing.CreateBlankColorMatrix(newBigImageSize.Item1, newBigImageSize.Item2);

            int index = 0;
            int w     = 0;
            int h     = 0;

            bool reaply = false;

            foreach (ImportedImage img in imgList)
            {
                w = initialXFactor + /* * (1 + (index % imgPerLine))*/ +(newSize.Item1 - squishXFactor) * (index % imgPerLine) + newSize.Item1 / 2 + img.Pivot.Item1;
                h = initialYFactor + (newSize.Item2 - squishYFactor) * (index / imgPerLine) + newSize.Item2 / 2 + img.Pivot.Item2;

                if (!reaply)
                {
                    ImageProcessing.AddImageIntoMatrix(nCM1, img.BitmapImage, w, h);
                    ImageProcessing.AddImageIntoMatrix(nCM2, img.BitmapImage, w, h);
                }
                else
                {
                    ImageProcessing.BlendImageIntoMatrix(nCM1, img.BitmapImage, w, h, (y, x) =>
                    {
                        return(ColorBlending.MultiChannelAlphaBlending(x, y));
                    });

                    ImageProcessing.BlendImageIntoMatrix(nCM2, img.BitmapImage, w, h, (x, y) =>
                    {
                        return(ColorBlending.MultiChannelAlphaBlending(x, y));
                    });
                }

                if (++index == imagePerLayer[0] && !reaply)
                {
                    reaply = true;
                    index  = 0;
                }
            }

            ImageProcessing.BlendImageIntoMatrix(nCM1, ImageProcessing.CreateImage(nCM2), 0, 0, (x, y) =>
            {
                return(Color.FromArgb(Math.Max(x.A, y.A), Math.Max(x.R, y.R), Math.Max(x.G, y.G), Math.Max(x.B, y.B)));
            });

            ImageProcessing.CreateImage(nCM1).Save(Parameters.SpritesheetOutputDirectory + @"output.png");

            ExplorerHelper.OpenDirectory(Parameters.SpritesheetOutputDirectory);
            Thread.Sleep(1500);
            PaintHelper.OpenPictureFromOutputFolder(Parameters.SpritesheetOutputDirectory + @"output.png");
        }
Ejemplo n.º 4
0
 public static void setMaterialColor(Material m, Color c, ColorBlending colorBlending)
 {
     m.SetColor("_Color", c);
     m.SetInt("_ColorBlend", (int)colorBlending);
 }