예제 #1
0
        public override EffectLayer Render(IGameState gamestate)
        {
            EffectLayer gradient_layer = new EffectLayer();

            if (Properties.Sequence.type == KeySequenceType.Sequence)
            {
                temp_layer = new EffectLayer("Color Zone Effect", LayerEffects.GradientShift_Custom_Angle, Properties.GradientConfig);

                foreach (var key in Properties.Sequence.keys)
                {
                    gradient_layer.Set(key, Utils.ColorUtils.AddColors(gradient_layer.Get(key), temp_layer.Get(key)));
                }
            }
            else
            {
                float x_pos  = (float)Math.Round((Properties.Sequence.freeform.X + Effects.grid_baseline_x) * Effects.editor_to_canvas_width);
                float y_pos  = (float)Math.Round((Properties.Sequence.freeform.Y + Effects.grid_baseline_y) * Effects.editor_to_canvas_height);
                float width  = (float)Math.Round((double)(Properties.Sequence.freeform.Width * Effects.editor_to_canvas_width));
                float height = (float)Math.Round((double)(Properties.Sequence.freeform.Height * Effects.editor_to_canvas_height));

                if (width < 3)
                {
                    width = 3;
                }
                if (height < 3)
                {
                    height = 3;
                }

                Rectangle rect = new Rectangle((int)x_pos, (int)y_pos, (int)width, (int)height);

                temp_layer = new EffectLayer("Color Zone Effect", LayerEffects.GradientShift_Custom_Angle, Properties.GradientConfig, rect);

                using (Graphics g = gradient_layer.GetGraphics())
                {
                    PointF rotatePoint = new PointF(x_pos + (width / 2.0f), y_pos + (height / 2.0f));

                    Matrix myMatrix = new Matrix();
                    myMatrix.RotateAt(Properties.Sequence.freeform.Angle, rotatePoint, MatrixOrder.Append);

                    g.Transform = myMatrix;
                    g.DrawImage(temp_layer.GetBitmap(), rect, rect, GraphicsUnit.Pixel);
                }
            }

            return(gradient_layer);
        }
예제 #2
0
        public override EffectLayer Render(IGameState gamestate)
        {
            EffectLayer gradient_layer = new EffectLayer();

            //If Wave Size 0 Gradiant Stop Moving Animation
            if (Properties.GradientConfig.gradient_size == 0)
            {
                Properties.GradientConfig.shift_amount    += ((Utils.Time.GetMillisecondsSinceEpoch() - Properties.GradientConfig.last_effect_call) / 1000.0f) * 5.0f * Properties.GradientConfig.speed;
                Properties.GradientConfig.shift_amount     = Properties.GradientConfig.shift_amount % Effects.canvas_biggest;
                Properties.GradientConfig.last_effect_call = Utils.Time.GetMillisecondsSinceEpoch();

                Color selected_color = Properties.GradientConfig.brush.GetColorSpectrum().GetColorAt(Properties.GradientConfig.shift_amount, Effects.canvas_biggest);

                gradient_layer.Set(Properties.Sequence, selected_color);
            }
            else if (Properties.Sequence.type == KeySequenceType.Sequence)
            {
                using var temp_layer = new EffectLayer("Color Zone Effect", LayerEffects.GradientShift_Custom_Angle, Properties.GradientConfig);

                foreach (var key in Properties.Sequence.keys)
                {
                    gradient_layer.Set(key, temp_layer.Get(key));
                }
            }
            else
            {
                gradient_layer.DrawTransformed(
                    Properties.Sequence,
                    g =>
                {
                    var rect = new RectangleF(0, 0, Effects.canvas_width, Effects.canvas_height);
                    using var temp_layer_bitmap = new EffectLayer("Color Zone Effect", LayerEffects.GradientShift_Custom_Angle, Properties.GradientConfig, rect).GetBitmap();
                    g.DrawImage(temp_layer_bitmap, rect, rect, GraphicsUnit.Pixel);
                }
                    );
            }
            return(gradient_layer);
        }
예제 #3
0
        public void PushFrame(EffectFrame frame)
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            lock (bitmap_lock)
            {
                EffectLayer background = new EffectLayer("Global Background", Color.FromArgb(0, 0, 0));

                EffectLayer[] over_layers_array = frame.GetOverlayLayers().ToArray();
                EffectLayer[] layers_array      = frame.GetLayers().ToArray();

                foreach (EffectLayer layer in layers_array)
                {
                    background += layer;
                }

                foreach (EffectLayer layer in over_layers_array)
                {
                    background += layer;
                }

                //Apply Brightness
                Dictionary <DeviceKeys, Color> peripehralColors = new Dictionary <DeviceKeys, Color>();

                foreach (Devices.DeviceKeys key in possible_peripheral_keys)
                {
                    if (!peripehralColors.ContainsKey(key))
                    {
                        peripehralColors.Add(key, background.Get(key));
                    }
                }

                foreach (Devices.DeviceKeys key in possible_peripheral_keys)
                {
                    background.Set(key, Utils.ColorUtils.BlendColors(peripehralColors[key], Color.Black, (1.0f - Global.Configuration.PeripheralBrightness)));
                }

                background.Fill(Color.FromArgb((int)(255.0f * (1.0f - Global.Configuration.KeyboardBrightness)), Color.Black));

                if (Global.Configuration.use_volume_as_brightness)
                {
                    background *= Global.Configuration.GlobalBrightness;
                }

                if (_forcedFrame != null)
                {
                    using (Graphics g = background.GetGraphics())
                    {
                        g.Clear(Color.Black);

                        g.DrawImage(_forcedFrame, 0, 0, canvas_width, canvas_height);
                    }
                }

                Dictionary <DeviceKeys, Color> keyColors = new Dictionary <DeviceKeys, Color>();
                Devices.DeviceKeys[]           allKeys   = bitmap_map.Keys.ToArray();

                foreach (Devices.DeviceKeys key in allKeys)
                {
                    keyColors[key] = background.Get(key);
                }

                Effects.keyColors = new Dictionary <DeviceKeys, Color>(keyColors);

                pushedframes++;

                DeviceColorComposition dcc = new DeviceColorComposition()
                {
                    keyColors = new Dictionary <DeviceKeys, Color>(keyColors),
                    keyBitmap = background.GetBitmap()
                };

                Global.dev_manager.UpdateDevices(dcc);

                var hander = NewLayerRender;
                if (hander != null)
                {
                    hander.Invoke(background.GetBitmap());
                }

                if (isrecording)
                {
                    EffectLayer pizelated_render = new EffectLayer();
                    foreach (Devices.DeviceKeys key in allKeys)
                    {
                        pizelated_render.Set(key, background.Get(key));
                    }

                    using (Bitmap map = pizelated_render.GetBitmap())
                    {
                        previousframe = new Bitmap(map);
                    }
                }


                frame.Dispose();
            }

            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;
        }
예제 #4
0
        public override void UpdateLights(EffectFrame frame)
        {
            previoustime = currenttime;
            currenttime  = Utils.Time.GetMillisecondsSinceEpoch();

            Queue <EffectLayer> layers = new Queue <EffectLayer>();
            EffectLayer         layer;

            effect_cfg.speed = Global.Configuration.idle_speed;

            switch (Global.Configuration.idle_type)
            {
            case IdleEffects.Dim:
                layer = new EffectLayer("Idle - Dim");

                layer.Fill(Color.FromArgb(125, 0, 0, 0));

                layers.Enqueue(layer);
                break;

            case IdleEffects.ColorBreathing:
                layer = new EffectLayer("Idle - Color Breathing");

                Color breathe_bg_color = Global.Configuration.idle_effect_secondary_color;
                layer.Fill(breathe_bg_color);

                float sine = (float)Math.Pow(Math.Sin((double)((currenttime % 10000L) / 10000.0f) * 2 * Math.PI * Global.Configuration.idle_speed), 2);

                layer.Fill(Color.FromArgb((byte)(sine * 255), Global.Configuration.idle_effect_primary_color));

                layers.Enqueue(layer);
                break;

            case IdleEffects.RainbowShift_Horizontal:
                layer = new EffectLayer("Idle - Rainbow Shift (Horizontal)", LayerEffects.RainbowShift_Horizontal, effect_cfg);

                layers.Enqueue(layer);
                break;

            case IdleEffects.RainbowShift_Vertical:
                layer = new EffectLayer("Idle - Rainbow Shift (Vertical)", LayerEffects.RainbowShift_Vertical, effect_cfg);

                layers.Enqueue(layer);
                break;

            case IdleEffects.StarFall:
                layer = new EffectLayer("Idle - Starfall");

                if (nextstarset < currenttime)
                {
                    for (int x = 0; x < Global.Configuration.idle_amount; x++)
                    {
                        Devices.DeviceKeys star = allKeys[randomizer.Next(allKeys.Length)];
                        if (stars.ContainsKey(star))
                        {
                            stars[star] = 1.0f;
                        }
                        else
                        {
                            stars.Add(star, 1.0f);
                        }
                    }

                    nextstarset = currenttime + (long)(1000L * Global.Configuration.idle_frequency);
                }

                layer.Fill(Global.Configuration.idle_effect_secondary_color);

                Devices.DeviceKeys[] stars_keys = stars.Keys.ToArray();

                foreach (Devices.DeviceKeys star in stars_keys)
                {
                    layer.Set(star, Utils.ColorUtils.MultiplyColorByScalar(Global.Configuration.idle_effect_primary_color, stars[star]));
                    stars[star] -= getDeltaTime() * 0.05f * Global.Configuration.idle_speed;
                }

                layers.Enqueue(layer);
                break;

            case IdleEffects.RainFall:
                layer = new EffectLayer("Idle - Rainfall");

                if (nextstarset < currenttime)
                {
                    for (int x = 0; x < Global.Configuration.idle_amount; x++)
                    {
                        Devices.DeviceKeys star = allKeys[randomizer.Next(allKeys.Length)];
                        if (raindrops.ContainsKey(star))
                        {
                            raindrops[star] = 1.0f;
                        }
                        else
                        {
                            raindrops.Add(star, 1.0f);
                        }
                    }

                    nextstarset = currenttime + (long)(1000L * Global.Configuration.idle_frequency);
                }

                layer.Fill(Global.Configuration.idle_effect_secondary_color);

                Devices.DeviceKeys[] raindrops_keys = raindrops.Keys.ToArray();

                ColorSpectrum drop_spec = new ColorSpectrum(Global.Configuration.idle_effect_primary_color, Color.FromArgb(0, Global.Configuration.idle_effect_primary_color));

                foreach (Devices.DeviceKeys raindrop in raindrops_keys)
                {
                    PointF pt = Effects.GetBitmappingFromDeviceKey(raindrop).Center;

                    float transition_value = 1.0f - raindrops[raindrop];
                    float radius           = transition_value * Effects.canvas_biggest;

                    layer.GetGraphics().DrawEllipse(new Pen(drop_spec.GetColorAt(transition_value), 2),
                                                    pt.X - radius,
                                                    pt.Y - radius,
                                                    2 * radius,
                                                    2 * radius);

                    raindrops[raindrop] -= getDeltaTime() * 0.05f * Global.Configuration.idle_speed;
                }

                layers.Enqueue(layer);
                break;

            case IdleEffects.Blackout:
                layer = new EffectLayer("Idle - Blackout");

                layer.Fill(Color.Black);

                layers.Enqueue(layer);
                break;

            case IdleEffects.Matrix:
                layer = new EffectLayer("Idle - Matrix");

                if (nextstarset < currenttime)
                {
                    Color darker_primary = Utils.ColorUtils.MultiplyColorByScalar(Global.Configuration.idle_effect_primary_color, 0.50);

                    for (int x = 0; x < Global.Configuration.idle_amount; x++)
                    {
                        int   width_start = randomizer.Next(Effects.canvas_width);
                        float delay       = randomizer.Next(550) / 100.0f;
                        int   random_id   = randomizer.Next(125536789);

                        //Create animation
                        AnimationTrack matrix_line =
                            new AnimationTrack("Matrix Line (Head) " + random_id, 0.0f).SetFrame(
                                0.0f * 1.0f / (0.05f * Global.Configuration.idle_speed), new AnimationLine(width_start, -3, width_start, 0, Global.Configuration.idle_effect_primary_color, 3)).SetFrame(
                                0.5f * 1.0f / (0.05f * Global.Configuration.idle_speed), new AnimationLine(width_start, Effects.canvas_height, width_start, Effects.canvas_height + 3, Global.Configuration.idle_effect_primary_color, 3)).SetShift(
                                (currenttime % 1000000L) / 1000.0f + delay
                                );

                        AnimationTrack matrix_line_trail =
                            new AnimationTrack("Matrix Line (Trail) " + random_id, 0.0f).SetFrame(
                                0.0f * 1.0f / (0.05f * Global.Configuration.idle_speed), new AnimationLine(width_start, -12, width_start, -3, darker_primary, 3)).SetFrame(
                                0.5f * 1.0f / (0.05f * Global.Configuration.idle_speed), new AnimationLine(width_start, Effects.canvas_height - 12, width_start, Effects.canvas_height, darker_primary, 3)).SetFrame(
                                0.75f * 1.0f / (0.05f * Global.Configuration.idle_speed), new AnimationLine(width_start, Effects.canvas_height, width_start, Effects.canvas_height, darker_primary, 3)).SetShift(
                                (currenttime % 1000000L) / 1000.0f + delay
                                );

                        matrix_lines.AddTrack(matrix_line);
                        matrix_lines.AddTrack(matrix_line_trail);
                    }

                    nextstarset = currenttime + (long)(1000L * Global.Configuration.idle_frequency);
                }

                layer.Fill(Global.Configuration.idle_effect_secondary_color);

                using (Graphics g = layer.GetGraphics())
                {
                    matrix_lines.Draw(g, (currenttime % 1000000L) / 1000.0f);
                }

                layers.Enqueue(layer);
                break;

            case IdleEffects.RainFallSmooth:
                layer = new EffectLayer("Idle - RainfallSmooth");

                if (nextstarset < currenttime)
                {
                    for (int x = 0; x < Global.Configuration.idle_amount; x++)
                    {
                        Devices.DeviceKeys star = allKeys[randomizer.Next(allKeys.Length)];
                        if (raindrops.ContainsKey(star))
                        {
                            raindrops[star] = 1.0f;
                        }
                        else
                        {
                            raindrops.Add(star, 1.0f);
                        }
                    }

                    nextstarset = currenttime + (long)(1000L * Global.Configuration.idle_frequency);
                }
                layer.Fill(Global.Configuration.idle_effect_secondary_color);

                ColorSpectrum drop_spec2 = new ColorSpectrum(
                    Global.Configuration.idle_effect_primary_color,
                    Color.FromArgb(0, Global.Configuration.idle_effect_primary_color));

                var drops = raindrops.Keys.ToArray().Select(d =>
                {
                    PointF pt             = Effects.GetBitmappingFromDeviceKey(d).Center;
                    float transitionValue = 1.0f - raindrops[d];
                    float radius          = transitionValue * Effects.canvas_biggest;
                    raindrops[d]         -= getDeltaTime() * 0.05f * Global.Configuration.idle_speed;
                    return(new Tuple <Devices.DeviceKeys, PointF, float, float>(d, pt, transitionValue, radius));
                }).Where(d => d.Item3 <= 1.5).ToArray();

                float circleHalfThickness = 1f;

                foreach (var key in allKeys)
                {
                    var keyInfo = Effects.GetBitmappingFromDeviceKey(key);

                    // For easy calculation every button considered as circle with this radius
                    var btnRadius = ((keyInfo.Width + keyInfo.Height) / 4f);
                    if (btnRadius <= 0)
                    {
                        continue;
                    }

                    foreach (var raindrop in drops)
                    {
                        float circleInEdge  = (raindrop.Item4 - circleHalfThickness);
                        float circleOutEdge = (raindrop.Item4 + circleHalfThickness);
                        circleInEdge  *= circleInEdge;
                        circleOutEdge *= circleOutEdge;

                        float xKey        = Math.Abs(keyInfo.Center.X - raindrop.Item2.X);
                        float yKey        = Math.Abs(keyInfo.Center.Y - raindrop.Item2.Y);
                        float xKeyInEdge  = xKey - btnRadius;
                        float xKeyOutEdge = xKey + btnRadius;
                        float yKeyInEdge  = yKey - btnRadius;
                        float yKeyOutEdge = yKey + btnRadius;
                        float keyInEdge   = xKeyInEdge * xKeyInEdge + yKeyInEdge * yKeyInEdge;
                        float keyOutEdge  = xKeyOutEdge * xKeyOutEdge + yKeyOutEdge * yKeyOutEdge;

                        var btnDiameter    = keyOutEdge - keyInEdge;
                        var inEdgePercent  = (circleOutEdge - keyInEdge) / btnDiameter;
                        var outEdgePercent = (keyOutEdge - circleInEdge) / btnDiameter;
                        var percent        = Math.Min(1, Math.Max(0, inEdgePercent))
                                             + Math.Min(1, Math.Max(0, outEdgePercent)) - 1f;

                        if (percent > 0)
                        {
                            layer.Set(key, (Color)EffectColor.BlendColors(
                                          new EffectColor(layer.Get(key)),
                                          new EffectColor(drop_spec2.GetColorAt(raindrop.Item3)), percent));
                        }
                    }
                }
                layers.Enqueue(layer);
                break;

            default:
                break;
            }

            frame.AddOverlayLayers(layers.ToArray());
        }
예제 #5
0
        public override EffectLayer Render(IGameState gamestate)
        {
            EffectLayer image_layer = new EffectLayer();

            if (!String.IsNullOrWhiteSpace(Properties.ImagePath))
            {
                if (!_loaded_image_path.Equals(Properties.ImagePath))
                {
                    //Not loaded, load it!

                    _loaded_image      = new Bitmap(Properties.ImagePath);
                    _loaded_image_path = Properties.ImagePath;

                    if (Properties.ImagePath.EndsWith(".gif") && ImageAnimator.CanAnimate(_loaded_image))
                    {
                        ImageAnimator.Animate(_loaded_image, null);
                    }
                }

                if (Properties.ImagePath.EndsWith(".gif") && ImageAnimator.CanAnimate(_loaded_image))
                {
                    ImageAnimator.UpdateFrames(_loaded_image);
                }

                temp_layer = new EffectLayer("Temp Image Render");

                if (Properties.Sequence.type == KeySequenceType.Sequence)
                {
                    using (Graphics g = temp_layer.GetGraphics())
                    {
                        g.DrawImage(_loaded_image, new RectangleF(0, 0, Effects.canvas_width, Effects.canvas_height), new RectangleF(0, 0, _loaded_image.Width, _loaded_image.Height), GraphicsUnit.Pixel);
                    }

                    foreach (var key in Properties.Sequence.keys)
                    {
                        image_layer.Set(key, Utils.ColorUtils.AddColors(image_layer.Get(key), temp_layer.Get(key)));
                    }
                }
                else
                {
                    float x_pos  = (float)Math.Round((Properties.Sequence.freeform.X + Effects.grid_baseline_x) * Effects.editor_to_canvas_width);
                    float y_pos  = (float)Math.Round((Properties.Sequence.freeform.Y + Effects.grid_baseline_y) * Effects.editor_to_canvas_height);
                    float width  = (float)Math.Round((double)(Properties.Sequence.freeform.Width * Effects.editor_to_canvas_width));
                    float height = (float)Math.Round((double)(Properties.Sequence.freeform.Height * Effects.editor_to_canvas_height));

                    if (width < 3)
                    {
                        width = 3;
                    }
                    if (height < 3)
                    {
                        height = 3;
                    }

                    Rectangle rect = new Rectangle((int)x_pos, (int)y_pos, (int)width, (int)height);

                    using (Graphics g = temp_layer.GetGraphics())
                    {
                        g.DrawImage(_loaded_image, rect, new RectangleF(0, 0, _loaded_image.Width, _loaded_image.Height), GraphicsUnit.Pixel);
                    }

                    using (Graphics g = image_layer.GetGraphics())
                    {
                        PointF rotatePoint = new PointF(x_pos + (width / 2.0f), y_pos + (height / 2.0f));

                        Matrix myMatrix = new Matrix();
                        myMatrix.RotateAt(Properties.Sequence.freeform.Angle, rotatePoint, MatrixOrder.Append);

                        g.Transform = myMatrix;
                        g.DrawImage(temp_layer.GetBitmap(), rect, rect, GraphicsUnit.Pixel);
                    }
                }
            }

            return(image_layer);
        }
예제 #6
0
        public override EffectLayer Render(IGameState gamestate)
        {
            EffectLayer gradient_layer = new EffectLayer();

            //If Wave Size 0 Gradiant Stop Moving Animation
            if (Properties.GradientConfig.gradient_size == 0)
            {
                Properties.GradientConfig.shift_amount    += ((Utils.Time.GetMillisecondsSinceEpoch() - Properties.GradientConfig.last_effect_call) / 1000.0f) * 5.0f * Properties.GradientConfig.speed;
                Properties.GradientConfig.shift_amount     = Properties.GradientConfig.shift_amount % Effects.canvas_biggest;
                Properties.GradientConfig.last_effect_call = Utils.Time.GetMillisecondsSinceEpoch();

                Color selected_color = Properties.GradientConfig.brush.GetColorSpectrum().GetColorAt(Properties.GradientConfig.shift_amount, Effects.canvas_biggest);

                gradient_layer.Set(Properties.Sequence, selected_color);
            }
            else
            {
                if (Properties.Sequence.type == KeySequenceType.Sequence)
                {
                    temp_layer = new EffectLayer("Color Zone Effect", LayerEffects.GradientShift_Custom_Angle, Properties.GradientConfig);

                    foreach (var key in Properties.Sequence.keys)
                    {
                        gradient_layer.Set(key, Utils.ColorUtils.AddColors(gradient_layer.Get(key), temp_layer.Get(key)));
                    }
                }
                else
                {
                    float x_pos = (float)Math.Round((Properties.Sequence.freeform.X + Effects.grid_baseline_x) * Effects.editor_to_canvas_width);
                    float y_pos = (float)Math.Round((Properties.Sequence.freeform.Y + Effects.grid_baseline_y) * Effects.editor_to_canvas_height);

                    float width  = (float)Math.Round((double)(Properties.Sequence.freeform.Width * Effects.editor_to_canvas_width));
                    float height = (float)Math.Round((double)(Properties.Sequence.freeform.Height * Effects.editor_to_canvas_height));

                    if (width < 3)
                    {
                        width = 3;
                    }
                    if (height < 3)
                    {
                        height = 3;
                    }

                    Rectangle rect = new Rectangle((int)x_pos, (int)y_pos, (int)width, (int)height);

                    temp_layer = new EffectLayer("Color Zone Effect", LayerEffects.GradientShift_Custom_Angle, Properties.GradientConfig, rect);

                    using (Graphics g = gradient_layer.GetGraphics())
                    {
                        PointF rotatePoint = new PointF(x_pos + (width / 2.0f), y_pos + (height / 2.0f));

                        Matrix myMatrix = new Matrix();
                        myMatrix.RotateAt(Properties.Sequence.freeform.Angle, rotatePoint, MatrixOrder.Append);

                        g.Transform = myMatrix;
                        g.DrawImage(temp_layer.GetBitmap(), rect, rect, GraphicsUnit.Pixel);
                    }
                }
            }
            return(gradient_layer);
        }
예제 #7
0
        public override EffectLayer Render(IGameState state)
        {
            EffectLayer items_layer = new EffectLayer("Dota 2 - Items");

            if (state is GameState_Dota2)
            {
                GameState_Dota2 dota2state = state as GameState_Dota2;

                if (Properties.ItemKeys.Count >= 6)
                {
                    for (int index = 0; index < dota2state.Items.InventoryCount; index++)
                    {
                        Item item = dota2state.Items.GetInventoryAt(index);
                        Devices.DeviceKeys key = Properties.ItemKeys[index];

                        if (item.Name.Equals("empty"))
                        {
                            items_layer.Set(key, Properties.EmptyItemColor);
                        }
                        else
                        {
                            if (Properties.UseItemColors && item_colors.ContainsKey(item.Name))
                            {
                                if (!String.IsNullOrWhiteSpace(item.ContainsRune))
                                {
                                    items_layer.Set(key, Utils.ColorUtils.BlendColors(item_colors[item.Name], bottle_rune_colors[item.ContainsRune], 0.8));
                                }
                                else
                                {
                                    items_layer.Set(key, item_colors[item.Name]);
                                }
                            }
                            else
                            {
                                items_layer.Set(key, Properties.ItemsColor);
                            }

                            //Cooldown
                            if (item.Cooldown > 5)
                            {
                                items_layer.Set(key, Utils.ColorUtils.BlendColors(items_layer.Get(key), Properties.ItemCooldownColor, 1.0));
                            }
                            else if (item.Cooldown > 0 && item.Cooldown <= 5)
                            {
                                items_layer.Set(key, Utils.ColorUtils.BlendColors(items_layer.Get(key), Properties.ItemCooldownColor, item.Cooldown / 5.0));
                            }

                            //Charges
                            if (item.Charges == 0)
                            {
                                items_layer.Set(key, Utils.ColorUtils.BlendColors(items_layer.Get(key), Properties.ItemNoChargersColor, 0.7));
                            }
                        }
                    }

                    for (int index = 0; index < dota2state.Items.StashCount; index++)
                    {
                        Item item = dota2state.Items.GetStashAt(index);
                        Devices.DeviceKeys key = Properties.ItemKeys[6 + index];

                        if (item.Name.Equals("empty"))
                        {
                            items_layer.Set(key, Properties.EmptyItemColor);
                        }
                        else
                        {
                            if (Properties.UseItemColors && item_colors.ContainsKey(item.Name))
                            {
                                if (!String.IsNullOrWhiteSpace(item.ContainsRune))
                                {
                                    items_layer.Set(key, Utils.ColorUtils.BlendColors(item_colors[item.Name], bottle_rune_colors[item.ContainsRune], 0.8));
                                }
                                else
                                {
                                    items_layer.Set(key, item_colors[item.Name]);
                                }
                            }
                            else
                            {
                                items_layer.Set(key, Properties.ItemsColor);
                            }

                            //Cooldown
                            if (item.Cooldown > 5)
                            {
                                items_layer.Set(key, Utils.ColorUtils.BlendColors(items_layer.Get(key), Properties.ItemCooldownColor, 1.0));
                            }
                            else if (item.Cooldown > 0 && item.Cooldown <= 5)
                            {
                                items_layer.Set(key, Utils.ColorUtils.BlendColors(items_layer.Get(key), Properties.ItemCooldownColor, item.Cooldown / 5.0));
                            }

                            //Charges
                            if (item.Charges == 0)
                            {
                                items_layer.Set(key, Utils.ColorUtils.BlendColors(items_layer.Get(key), Properties.ItemNoChargersColor, 0.7));
                            }
                        }
                    }
                }
            }

            return(items_layer);
        }
예제 #8
0
        public void PushFrame(EffectFrame frame)
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            lock (bitmap_lock)
            {
                EffectLayer background = new EffectLayer("Global Background", Color.FromArgb(0, 0, 0));

                EffectLayer[] over_layers_array = frame.GetOverlayLayers().ToArray();
                EffectLayer[] layers_array      = frame.GetLayers().ToArray();

                foreach (EffectLayer layer in layers_array)
                {
                    background += layer;
                }

                foreach (EffectLayer layer in over_layers_array)
                {
                    background += layer;
                }

                //Apply Brightness
                Color peri_col = background.Get(DeviceKeys.Peripheral);

                background.Set(DeviceKeys.Peripheral, Utils.ColorUtils.BlendColors(peri_col, Color.Black, (1.0f - Global.Configuration.peripheral_brightness_modifier)));
                background.Fill(Color.FromArgb((int)(255.0f * (1.0f - Global.Configuration.keyboard_brightness_modifier)), Color.Black));

                if (Global.Configuration.use_volume_as_brightness)
                {
                    background *= Global.Configuration.global_brightness;
                }

                Dictionary <DeviceKeys, Color> keyColors = new Dictionary <DeviceKeys, Color>();
                Devices.DeviceKeys[]           allKeys   = bitmap_map.Keys.ToArray();

                foreach (Devices.DeviceKeys key in allKeys)
                {
                    keyColors[key] = background.Get(key);
                }

                Effects.keyColors = new Dictionary <DeviceKeys, Color>(keyColors);

                pushedframes++;
                Global.dev_manager.UpdateDevices(keyColors);

                var hander = NewLayerRender;

                if (hander != null)
                {
                    hander.Invoke(background.GetBitmap());
                }

                if (isrecording)
                {
                    EffectLayer pizelated_render = new EffectLayer();
                    foreach (Devices.DeviceKeys key in allKeys)
                    {
                        pizelated_render.Set(key, background.Get(key));
                    }

                    using (Bitmap map = pizelated_render.GetBitmap())
                    {
                        previousframe = new Bitmap(map);
                    }
                }


                frame.Dispose();
            }

            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;
        }