Пример #1
0
        public float PaintAt(PaintLayer layer, Color color, byte glow, float pressurePercent, ushort tileX, ushort tileY)
        {
            if (!layer.CanPaintAt(Main.tile[tileX, tileY]))
            {
                return(0f);
            }

            Color?oldColor;
            byte  oldGlow;

            Color blendedColor = PaintBrush.GetBlendedColor(layer, color, pressurePercent, tileX, tileY, out oldColor);
            byte  blendedGlow  = PaintBrush.GetBlendedGlow(layer, glow, pressurePercent, tileX, tileY, out oldGlow);

            layer.SetRawColorAt(blendedColor, tileX, tileY);
            layer.SetGlowAt(blendedGlow, tileX, tileY);

            float diff = PaintBrush.ComputeChangePercent(oldColor, blendedColor, oldGlow, blendedGlow);

            if (diff <= 0.01f)
            {
                pressurePercent = 0f;
            }

            return(pressurePercent);
            //return PaintBrush.ComputeColorChangePercent( existing_color, lerped_color );
        }
Пример #2
0
        public float PaintAt(PaintLayer layer, Color color, byte glow, float pressurePercent, float brushRadius, float dist,
                             ushort tileX, ushort tileY)
        {
            if (!layer.CanPaintAt(Main.tile[tileX, tileY]))
            {
                return(0f);
            }

            float distPressurePercent = MathHelper.Clamp(pressurePercent * (1f - (dist / brushRadius)), 0f, 1f);

            Color?oldColor;
            byte  oldGlow;

            Color blendedColor = PaintBrush.GetBlendedColor(layer, color, distPressurePercent, tileX, tileY, out oldColor);
            byte  blendedGlow  = PaintBrush.GetBlendedGlow(layer, glow, distPressurePercent, tileX, tileY, out oldGlow);

            layer.SetRawColorAt(blendedColor, tileX, tileY);
            layer.SetGlowAt(blendedGlow, tileX, tileY);

            float diff = PaintBrush.ComputeChangePercent(oldColor, blendedColor, oldGlow, blendedGlow);

            if (diff <= 0.01f)
            {
                distPressurePercent = 0f;
            }

            return(distPressurePercent);
        }
Пример #3
0
        public void EraseAt(PaintLayer layer, float pressurePercent, ushort tileX, ushort tileY)
        {
            if (!layer.CanPaintAt(Main.tile[tileX, tileY]))
            {
                return;
            }
            if (!layer.HasColorAt(tileX, tileY))
            {
                return;
            }

            int tolerance = (int)(pressurePercent * 255f);

            Color?oldColor;
            byte  oldGlow;

            Color blendedColor = PaintBrush.GetErasedColor(layer, pressurePercent, tileX, tileY, out oldColor);
            byte  blendedGlow  = PaintBrush.GetBlendedGlow(layer, 0, pressurePercent, tileX, tileY, out oldGlow);

            float diff = PaintBrush.ComputeChangePercent(oldColor, blendedColor, oldGlow, blendedGlow);

            if (diff <= 0.01f)
            {
                layer.RemoveRawColorAt(tileX, tileY);
                layer.RemoveGlowAt(tileX, tileY);
            }
            else
            {
                layer.SetRawColorAt(blendedColor, tileX, tileY);
                layer.SetGlowAt(blendedGlow, tileX, tileY);
            }
        }