예제 #1
0
        ////////////////

        public static Color GetBlendedColor(PaintLayer layer, Color rgbColor, float pressurePercent, ushort tileX, ushort tileY,
                                            out Color?oldColor)
        {
            Color blendedColor;
            float oldPressurePercent;

            oldColor = layer.GetRawColorAt(tileX, tileY);

            if (oldColor != null)
            {
                Color oldRgbColor = (Color)oldColor;

                oldPressurePercent = oldRgbColor.A / 255f;
                float oldPressurePercentOffset = (1f - pressurePercent) * oldPressurePercent;

                blendedColor = Color.Lerp(rgbColor, oldRgbColor, oldPressurePercentOffset);
            }
            else
            {
                oldPressurePercent = 0f;
                blendedColor       = rgbColor;
            }

            blendedColor.A = (byte)(MathHelper.Lerp(oldPressurePercent, 1f, pressurePercent) * 255f);

            return(blendedColor);
        }
예제 #2
0
        public static Color GetErasedColor(PaintLayer layer, float pressurePercent, ushort tileX, ushort tileY, out Color?oldColor)
        {
            oldColor = layer.GetRawColorAt(tileX, tileY);
            if (oldColor == null)
            {
                return(Color.Transparent);
            }

            Color blendedColor = (Color)oldColor;

            blendedColor.A = (byte)(MathHelper.Lerp(blendedColor.A, 0f, pressurePercent) * 255f);

            return(blendedColor);
        }