예제 #1
0
        public override void Draw(GameTime gameTime, Point mousePos)
        {
            base.Draw(gameTime, mousePos);
            if (!showingPulse)
            {
                i++;
                if (i <= PulseDelay)
                {
                    return;
                }
                showingPulse = true;
                i            = 0;
                pulseX       = -halfPulseWidth;
                return;
            }

            var start = (int)(bounds.X + pulseX);
            var bound = new Rectangle(bounds.X + 1, bounds.Y + 1, Filled, bounds.Height - 2);

            //var halfPulseWidth = (int) (Filled * PulseWidthProportion / 2);
            for (var x = 0; x < halfPulseWidth; x++)
            {
                var whiten = 0.7f * (1 - (float)Math.Pow((double)x / halfPulseWidth, 1.25));
                var color  = FillColor.Interpolate(PulseColor, whiten);
                Drawing.DrawVerticalLine(start + x, color, bound);
                Drawing.DrawVerticalLine(start - x, color, bound);
            }

            //pulse speeds up as it progresses
            if (!Pause)
            {
                pulseX += PulseSpeed * (0.7f + 1f * (pulseX + halfPulseWidth) / (Filled + halfPulseWidth * 2));
            }
            if (pulseX < Filled + halfPulseWidth)
            {
                return;
            }

            showingPulse = false;
        }