コード例 #1
0
        private void Draw()
        {
            uint color = (uint)SimulatorUtils.GetComputerColor(0x000000)
                         | (uint)0xFF000000;

            for (int i = 0; i < this.config.stageSideLengths.Length; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    var    pt1     = GetPoint(i, j, 0);
                    var    pt2     = GetPoint(i, j, 1);
                    int    numLEDs = this.config.stageSideLengths[i];
                    double deltaX  = (pt1.Item1 - pt2.Item1) / (numLEDs + 2.0);
                    double deltaY  = (pt1.Item2 - pt2.Item2) / (numLEDs + 2.0);
                    for (int k = 0; k < numLEDs; k++)
                    {
                        int x = pt1.Item1 - (int)(deltaX * (k + 1));
                        int y = pt1.Item2 - (int)(deltaY * (k + 1));
                        this.SetPixelColor(this.pixels, x, y, color);
                    }
                }
            }
            this.bitmap.WritePixels(this.rect, this.pixels, this.rect.Width * 4, 0);
            this.image.Source = this.bitmap;
        }
コード例 #2
0
        private void ShowKey(object sender, RoutedEventArgs e)
        {
            this.keyMode = !this.keyMode;
            foreach (Label sideLabel in this.sideLabels)
            {
                sideLabel.Visibility = this.keyMode
          ? Visibility.Visible
          : Visibility.Collapsed;
            }
            this.showKey.Content = this.keyMode
        ? "Hide Key"
        : "Show Key";
            this.directionLabel.Visibility = this.keyMode
        ? Visibility.Visible
        : Visibility.Collapsed;
            this.previewBox.Visibility = this.keyMode
        ? Visibility.Visible
        : Visibility.Collapsed;

            if (!this.keyMode)
            {
                this.bitmap.WritePixels(this.rect, this.pixels, this.rect.Width * 4, 0);
                return;
            }

            var keyPixels = new byte[rect.Width * rect.Height * 4];

            for (int x = 0; x < rect.Width; x++)
            {
                for (int y = 0; y < rect.Height; y++)
                {
                    this.SetPixelColor(keyPixels, x, y, (uint)0xFF000000);
                }
            }

            uint color = (uint)SimulatorUtils.GetComputerColor(0xFFFFFF)
                         | (uint)0xFF000000;

            for (int i = 0; i < this.config.stageSideLengths.Length; i++)
            {
                var    pt1     = GetPoint(i, 1, 0);
                var    pt2     = GetPoint(i, 1, 1);
                int    numLEDs = this.config.stageSideLengths[i];
                double deltaX  = (pt1.Item1 - pt2.Item1) / (numLEDs + 2.0);
                double deltaY  = (pt1.Item2 - pt2.Item2) / (numLEDs + 2.0);
                // Only light up the first 3/4 pixels
                for (int k = 0; k < numLEDs * 3 / 4; k++)
                {
                    int x = pt1.Item1 - (int)(deltaX * (k + 1));
                    int y = pt1.Item2 - (int)(deltaY * (k + 1));
                    this.SetPixelColor(keyPixels, x, y, color);
                }
            }

            this.bitmap.WritePixels(this.rect, keyPixels, this.rect.Width * 4, 0);
        }
コード例 #3
0
        private void ShowKey(object sender, RoutedEventArgs e)
        {
            this.keyMode = !this.keyMode;
            foreach (Label strutLabel in this.strutLabels)
            {
                strutLabel.Visibility = this.keyMode
          ? Visibility.Visible
          : Visibility.Collapsed;
            }
            this.showKey.Content = this.keyMode
        ? "Hide Key"
        : "Show Key";
            this.directionLabel.Visibility = this.keyMode
        ? Visibility.Visible
        : Visibility.Collapsed;
            this.previewBox.Visibility = this.keyMode
        ? Visibility.Visible
        : Visibility.Collapsed;

            if (!this.keyMode)
            {
                this.bitmap.WritePixels(this.rect, this.pixels, this.rect.Width * 4, 0);
                return;
            }

            var strutPixels = new byte[rect.Width * rect.Height * 4];

            for (int x = 0; x < rect.Width; x++)
            {
                for (int y = 0; y < rect.Height; y++)
                {
                    this.SetPixelColor(strutPixels, x, y, (uint)0xFF000000);
                }
            }

            uint color = (uint)SimulatorUtils.GetComputerColor(0xFFFFFF)
                         | (uint)0xFF000000;

            for (int i = 0; i < LEDDomeOutput.GetNumStruts(); i++)
            {
                var    pt1     = GetPoint(i, 0);
                var    pt2     = GetPoint(i, 1);
                int    numLEDs = LEDDomeOutput.GetNumLEDs(i);
                double deltaX  = (pt1.Item1 - pt2.Item1) / (numLEDs + 2.0);
                double deltaY  = (pt1.Item2 - pt2.Item2) / (numLEDs + 2.0);
                for (int j = 0; j < numLEDs * 3 / 4; j++)
                {
                    int x = pt1.Item1 - (int)(deltaX * (j + 1));
                    int y = pt1.Item2 - (int)(deltaY * (j + 1));
                    this.SetPixelColor(strutPixels, x, y, color);
                }
            }

            this.bitmap.WritePixels(this.rect, strutPixels, this.rect.Width * 4, 0);
        }
コード例 #4
0
        private void Draw()
        {
            uint color = (uint)SimulatorUtils.GetComputerColor(0x000000)
                         | (uint)0xFF000000;
            var max = 2 * this.config.barInfinityLength + 2 * this.config.barInfinityWidth;

            for (int i = 0; i < max; i++)
            {
                this.SetInfinityPixel(i, color);
            }
            for (int i = 0; i < this.config.barRunnerLength; i++)
            {
                this.SetRunnerPixel(i, color);
            }
            this.image.Source = this.bitmap;
        }
コード例 #5
0
        private void Update(object sender, EventArgs e)
        {
            int queueLength = this.config.stageCommandQueue.Count;

            if (queueLength == 0)
            {
                return;
            }

            //Stopwatch stopwatch = Stopwatch.StartNew();

            bool shouldRedraw = false;

            for (int k = 0; k < queueLength; k++)
            {
                StageLEDCommand command;
                bool            result =
                    this.config.stageCommandQueue.TryDequeue(out command);
                if (!result)
                {
                    throw new Exception("Someone else is dequeueing!");
                }
                if (command.isFlush)
                {
                    shouldRedraw = true;
                    continue;
                }
                var    pt1     = GetPoint(command.sideIndex, command.layerIndex, 0);
                var    pt2     = GetPoint(command.sideIndex, command.layerIndex, 1);
                int    numLEDs = this.config.stageSideLengths[command.sideIndex];
                double deltaX  = (pt1.Item1 - pt2.Item1) / (numLEDs + 2.0);
                double deltaY  = (pt1.Item2 - pt2.Item2) / (numLEDs + 2.0);
                int    x       = pt1.Item1 - (int)(deltaX * (command.ledIndex + 1));
                int    y       = pt1.Item2 - (int)(deltaY * (command.ledIndex + 1));
                uint   color   = (uint)SimulatorUtils.GetComputerColor(command.color)
                                 | (uint)0xFF000000;
                this.SetPixelColor(this.pixels, x, y, color);
            }

            if (shouldRedraw && !this.keyMode)
            {
                this.bitmap.WritePixels(this.rect, this.pixels, this.rect.Width * 4, 0);
            }

            //Debug.WriteLine("StageSimulator took " + stopwatch.ElapsedMilliseconds + "ms to update");
        }
コード例 #6
0
        private void Draw()
        {
            uint color = (uint)SimulatorUtils.GetComputerColor(0x000000)
                         | (uint)0xFF000000;

            for (int i = 0; i < LEDDomeOutput.GetNumStruts(); i++)
            {
                var    pt1     = GetPoint(i, 0);
                var    pt2     = GetPoint(i, 1);
                int    numLEDs = LEDDomeOutput.GetNumLEDs(i);
                double deltaX  = (pt1.Item1 - pt2.Item1) / (numLEDs + 2.0);
                double deltaY  = (pt1.Item2 - pt2.Item2) / (numLEDs + 2.0);
                for (int j = 0; j < numLEDs; j++)
                {
                    int x = pt1.Item1 - (int)(deltaX * (j + 1));
                    int y = pt1.Item2 - (int)(deltaY * (j + 1));
                    this.SetPixelColor(this.pixels, x, y, color);
                }
            }
            this.bitmap.WritePixels(this.rect, this.pixels, this.rect.Width * 4, 0);
            this.image.Source = this.bitmap;
        }
コード例 #7
0
        private void Update(object sender, EventArgs e)
        {
            int queueLength = this.config.barCommandQueue.Count;

            if (queueLength == 0)
            {
                return;
            }

            //Stopwatch stopwatch = Stopwatch.StartNew();

            for (int k = 0; k < queueLength; k++)
            {
                BarLEDCommand command;
                bool          result =
                    this.config.barCommandQueue.TryDequeue(out command);
                if (!result)
                {
                    throw new Exception("Someone else is dequeueing!");
                }
                if (command.isFlush)
                {
                    continue;
                }
                uint color = (uint)SimulatorUtils.GetComputerColor(command.color)
                             | (uint)0xFF000000;
                if (command.isRunner)
                {
                    this.SetRunnerPixel(command.ledIndex, color);
                }
                else
                {
                    this.SetInfinityPixel(command.ledIndex, color);
                }
            }

            //Debug.WriteLine("BarSimulator took " + stopwatch.ElapsedMilliseconds + "ms to update");
        }