private void AnimationTimerTick(object state) { if (_drops != null & _drops.Length > 0) { // Black background with opacity to fade characters _fullScreenBitmap.DrawRectangle(colorOutline: _backgroundColour, thicknessOutline: 0, x: 0, y: 0, width: _fullScreenBitmap.Width, height: _fullScreenBitmap.Height, xCornerRadius: 0, yCornerRadius: 0, colorGradientStart: Color.Black, xGradientStart: 0, yGradientStart: 0, colorGradientEnd: Color.Black, xGradientEnd: _fullScreenBitmap.Width, yGradientEnd: _fullScreenBitmap.Height, opacity: 25); PointAndChar pac = new PointAndChar(); for (var i = 0; i < _drops.Length; i++) // looping over drops { // new drop position double x = _xOffset + _letterAdvanceWidth * i; double y = _yOffset + _letterAdvanceHeight * _drops[i]; // check if new letter does not go outside the image if (y + _letterAdvanceHeight < _fullScreenBitmap.Height) { char randomLetter = AvailableLetterChars[_random.Next(AvailableLetterChars.Length - 1)]; pac.x = (int)x; pac.y = (int)y; pac.Character = randomLetter.ToString(); } else { pac.Character = " "; } //sending the drop back to the top randomly after it has crossed the image //adding a randomness to the reset to make the drops scattered on the Y axis if (_drops[i] * _letterAdvanceHeight > _fullScreenBitmap.Height && _random.Next(1000) > 850) { _drops[i] = 0; } _fullScreenBitmap.DrawText(pac.Character, _matrixFont, _textColour, pac.x, pac.y); //incrementing Y coordinate _drops[i]++; } _fullScreenBitmap.Flush(); } }
private void _animationTimer_Tick(object state) { if (Drops != null & Drops.Length > 0) { //Black BG with opacity to fade characters FullScreenBitmap.DrawRectangle(colorOutline: BackgroundColour, thicknessOutline: 0, x: 0, y: 0, width: FullScreenBitmap.Width, height: FullScreenBitmap.Height, xCornerRadius: 0, yCornerRadius: 0, colorGradientStart: Color.Black, xGradientStart: 0, yGradientStart: 0, colorGradientEnd: Color.Black, xGradientEnd: FullScreenBitmap.Width, yGradientEnd: FullScreenBitmap.Height, opacity: 25); PointAndChar pac = new PointAndChar(); for (var i = 0; i < Drops.Length; i++) // looping over drops { // new drop position //double x = BaselineOrigin.x + LetterAdvanceWidth * i; //double y = BaselineOrigin.y + LetterAdvanceHeight * Drops[i]; double x = xOffset + LetterAdvanceWidth * i; double y = yOffset + LetterAdvanceHeight * Drops[i]; // check if new letter does not go outside the image if (y + LetterAdvanceHeight < FullScreenBitmap.Height) { char randomLetter = AvailableLetterChars[random.Next(AvailableLetterChars.Length - 1)]; pac.x = (int)x; pac.y = (int)y; pac.Character = randomLetter.ToString(); } else { pac.Character = " "; } //sending the drop back to the top randomly after it has crossed the image //adding a randomness to the reset to make the drops scattered on the Y axis if (Drops[i] * LetterAdvanceHeight > FullScreenBitmap.Height && random.NextDouble() > 0.775) { Drops[i] = 0; } FullScreenBitmap.DrawText(pac.Character, MatrixFont, TextColour, pac.x, pac.y); //incrementing Y coordinate Drops[i]++; } FullScreenBitmap.Flush(); } }