Esempio n. 1
0
        public List <LaserPositionAndColors> GetPredifinedLaserPositionAndColors()
        {
            return(new List <LaserPositionAndColors>
            {
                new LaserPositionAndColors
                {
                    X = _settings.maxLeft, Y = (_settings.minHeight + _settings.maxHeight) / 2,
                    LaserColors = _laserPatternHelper.GetRandomLaserColors()
                },

                new LaserPositionAndColors
                {
                    X = _settings.maxLeft + 20, Y = (_settings.minHeight + _settings.maxHeight) / 2,
                    LaserColors = _laserPatternHelper.GetRandomLaserColors()
                }
            });
        }
        public void Project(PatternOptions options)
        {
            int totalLines = 4;

            if (totalLines < 2)
            {
                totalLines = 2;
            }

            var stopwatch = new Stopwatch();

            stopwatch.Start();

            var colors = new List <LaserColors>();

            for (int i = 0; i < totalLines; i++)
            {
                colors.Add(_laserPatternHelper.GetRandomLaserColors());
            }

            AnimationSpeed animationSpeed = options.AnimationSpeed;
            double         iterations     = 0;

            while (stopwatch.ElapsedMilliseconds < options.DurationMilliseconds || iterations / 6.3 < options.Total)
            {
                iterations += (double)animationSpeed / 700;
                if (stopwatch.ElapsedMilliseconds > options.DurationMilliseconds && options.DurationMilliseconds != 0 || _laserAnimationStatus.AnimationCanceled)
                {
                    break;
                }
                if (options.AnimationSpeed == AnimationSpeed.NotSet)
                {
                    animationSpeed = _laserAnimationStatus.AnimationSpeed;
                }

                for (int line = 0; line < totalLines; line++)
                {
                    int x = Convert.ToInt32(Math.Cos(iterations + line) * Math.Abs(_settings.maxLeft));
                    int y = Convert.ToInt32(Math.Sin(iterations) * Math.Abs(2000));

                    _laser.SendTo(x, y);
                    System.Threading.Thread.SpinWait(40000);

                    _laser.On(colors[line]);

                    System.Threading.Thread.SpinWait(6000);
                    _laser.Off();
                }
            }
        }
 private List <LaserColors> GetRandomColors()
 {
     return(new List <LaserColors>
     {
         _laserPatternHelper.GetRandomLaserColors(),
         _laserPatternHelper.GetRandomLaserColors(),
         _laserPatternHelper.GetRandomLaserColors(),
         _laserPatternHelper.GetRandomLaserColors(),
         _laserPatternHelper.GetRandomLaserColors(),
         _laserPatternHelper.GetRandomLaserColors(),
         _laserPatternHelper.GetRandomLaserColors(),
     });
 }
Esempio n. 4
0
        public void Project(PatternOptions options)
        {
            LaserColors colors  = _laserPatternHelper.GetRandomLaserColors();
            int         xCenter = (_settings.maxLeft + _settings.maxRight) / 2;

            var stopwatch = new Stopwatch();

            stopwatch.Start();

            AnimationSpeed animationSpeed = options.AnimationSpeed;
            int            iterations     = 0;

            while (stopwatch.ElapsedMilliseconds < options.DurationMilliseconds || iterations < options.Total)
            {
                iterations++;
                if (options.AnimationSpeed == AnimationSpeed.NotSet)
                {
                    animationSpeed = _laserAnimationStatus.AnimationSpeed;
                }

                int left  = xCenter - 100;
                int right = xCenter + 100;

                int y = new Random(Guid.NewGuid().GetHashCode()).Next(_settings.minHeight, _settings.maxHeight);

                while (left > _settings.maxLeft || right < _settings.maxRight)
                {
                    if (stopwatch.ElapsedMilliseconds > options.DurationMilliseconds && options.DurationMilliseconds != 0 || _laserAnimationStatus.AnimationCanceled)
                    {
                        break;
                    }

                    _laser.SendTo(left -= (int)animationSpeed / 2, y);
                    System.Threading.Thread.SpinWait(30000);
                    _laser.On(colors);

                    _laser.SendTo(right += (int)animationSpeed / 2, y);
                    System.Threading.Thread.SpinWait(30000);
                    _laser.Off();
                    System.Threading.Thread.SpinWait(100);
                }
            }

            _laser.Off();
        }
        public void Project(PatternOptions options)
        {
            LaserColors colors    = _laserPatternHelper.GetRandomLaserColors();
            var         stopwatch = new Stopwatch();

            stopwatch.Start();

            AnimationSpeed animationSpeed = options.AnimationSpeed;
            var            xPos           = new List <int> {
                _settings.maxLeft, _settings.maxRight
            };
            double iterations = 0;

            while (stopwatch.ElapsedMilliseconds < options.DurationMilliseconds || iterations / 6.3 < options.Total)
            {
                iterations += (double)animationSpeed / 1400;
                if (options.AnimationSpeed == AnimationSpeed.NotSet)
                {
                    animationSpeed = _laserAnimationStatus.AnimationSpeed;
                }

                for (int line = 0; line < 2; line++)
                {
                    if (stopwatch.ElapsedMilliseconds > options.DurationMilliseconds && options.DurationMilliseconds != 0 || _laserAnimationStatus.AnimationCanceled)
                    {
                        break;
                    }

                    for (int j = 0; j < 3; j++)
                    {
                        int y = Convert.ToInt32(Math.Sin(iterations + line) * Math.Abs(2000));

                        _laser.SendTo(xPos[line], y);
                        System.Threading.Thread.SpinWait(15000);
                        _laser.On(colors);
                    }
                }
            }

            _laser.Off();
        }
Esempio n. 6
0
        public void Project(PatternOptions options)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            var color = _laserPatternHelper.GetRandomLaserColors();

            AnimationSpeed animationSpeed = options.AnimationSpeed;
            double         sin            = 0;
            int            iterations     = 0;

            while (stopwatch.ElapsedMilliseconds < options.DurationMilliseconds || iterations < options.Total * 2000)
            {
                if (stopwatch.ElapsedMilliseconds > options.DurationMilliseconds && options.DurationMilliseconds != 0 || _laserAnimationStatus.AnimationCanceled)
                {
                    break;
                }
                if (options.AnimationSpeed == AnimationSpeed.NotSet)
                {
                    animationSpeed = _laserAnimationStatus.AnimationSpeed;
                }

                for (int i = _settings.maxLeft; i < _settings.maxRight; i += 15)
                {
                    iterations++;
                    sin += 0.026;

                    int y = Convert.ToInt32(Math.Sin(sin) * Math.Abs(_settings.maxHeight));
                    _laser.SendTo(i, y);

                    if (i == _settings.maxLeft)
                    {
                        System.Threading.Thread.SpinWait(22000);
                    }
                    _laser.On(color);
                }

                _laser.Off();
            }
        }
Esempio n. 7
0
        public void Project(PatternOptions options)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            int iterations = 0;

            while (stopwatch.ElapsedMilliseconds < options.DurationMilliseconds || iterations < options.Total * 100)
            {
                iterations++;
                if (stopwatch.ElapsedMilliseconds > options.DurationMilliseconds && options.DurationMilliseconds != 0 || _laserAnimationStatus.AnimationCanceled)
                {
                    break;
                }

                LaserColors colors = _laserPatternHelper.GetRandomLaserColors();

                _laser.SendTo(_laserPatternHelper.GetRandomXPosition(), _laserPatternHelper.GetRandomYPosition());
                _laser.On(colors);
                System.Threading.Thread.SpinWait(20000);
                _laser.Off();
            }
        }
        public void Project(PatternOptions options)
        {
            LaserColors colors    = _laserPatternHelper.GetRandomLaserColors();
            var         stopwatch = new Stopwatch();

            stopwatch.Start();

            AnimationSpeed animationSpeed = options.AnimationSpeed;
            int            iterations     = 0;

            while (stopwatch.ElapsedMilliseconds < options.DurationMilliseconds || iterations < options.Total)
            {
                iterations++;

                for (int i = _settings.maxHeight; i > _settings.minHeight; i -= (int)animationSpeed)
                {
                    if (stopwatch.ElapsedMilliseconds > options.DurationMilliseconds && options.DurationMilliseconds != 0 || _laserAnimationStatus.AnimationCanceled)
                    {
                        break;
                    }
                    if (options.AnimationSpeed == AnimationSpeed.NotSet)
                    {
                        animationSpeed = _laserAnimationStatus.AnimationSpeed;
                    }

                    _laser.SendTo(_settings.maxLeft, i);
                    System.Threading.Thread.SpinWait(30000);
                    _laser.On(colors);

                    _laser.SendTo(_settings.maxRight, i);
                    System.Threading.Thread.SpinWait(30000);
                }
            }

            _laser.Off();
        }