public override EffectLayer Render(IGameState gamestate)
        {
            EffectLayer sc_assistant_layer = new EffectLayer("Shortcut Assistant");

            if (Global.held_modified == Keys.LControlKey || Global.held_modified == Keys.RControlKey)
            {
                if (Properties.DimBackground)
                {
                    sc_assistant_layer.Fill(Properties.DimColor);
                }

                if (Global.held_modified == Keys.LControlKey)
                {
                    sc_assistant_layer.Set(Devices.DeviceKeys.LEFT_CONTROL, Properties.CtrlKeyColor);
                }
                else
                {
                    sc_assistant_layer.Set(Devices.DeviceKeys.RIGHT_CONTROL, Properties.CtrlKeyColor);
                }
                sc_assistant_layer.Set(Properties.CtrlKeySequence, Properties.CtrlKeyColor);
            }
            else if (Global.held_modified == Keys.LMenu || Global.held_modified == Keys.RMenu)
            {
                if (Properties.DimBackground)
                {
                    sc_assistant_layer.Fill(Properties.DimColor);
                }

                if (Global.held_modified == Keys.LMenu)
                {
                    sc_assistant_layer.Set(Devices.DeviceKeys.LEFT_ALT, Properties.AltKeyColor);
                }
                else
                {
                    sc_assistant_layer.Set(Devices.DeviceKeys.RIGHT_ALT, Properties.AltKeyColor);
                }
                sc_assistant_layer.Set(Properties.AltKeySequence, Properties.AltKeyColor);
            }
            else if (Global.held_modified == Keys.LWin || Global.held_modified == Keys.RWin)
            {
                if (Properties.DimBackground)
                {
                    sc_assistant_layer.Fill(Properties.DimColor);
                }

                if (Global.held_modified == Keys.LWin)
                {
                    sc_assistant_layer.Set(Devices.DeviceKeys.LEFT_WINDOWS, Properties.WindowsKeyColor);
                }
                else
                {
                    sc_assistant_layer.Set(Devices.DeviceKeys.RIGHT_WINDOWS, Properties.WindowsKeyColor);
                }
                sc_assistant_layer.Set(Properties.WindowsKeySequence, Properties.WindowsKeyColor);
            }


            return(sc_assistant_layer);
        }
예제 #2
0
        public override EffectLayer Render(IGameState state)
        {
            if (isPlayingKillStreakAnimation && Utils.Time.GetMillisecondsSinceEpoch() >= ks_end_time)
            {
                isPlayingKillStreakAnimation = false;
            }

            EffectLayer killstreak_layer = new EffectLayer("Dota 2 - Killstreak");

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

                if (current_kill_count < dota2state.Player.Kills)
                {
                    isPlayingKillStreakAnimation = true;

                    ks_end_time = Utils.Time.GetMillisecondsSinceEpoch() + ks_duration;
                }
                current_kill_count = dota2state.Player.Kills;

                if (dota2state.Player.KillStreak >= 2)
                {
                    Color ks_color = getKillStreakColor(dota2state.Player.KillStreak);

                    killstreak_layer.Fill(Utils.ColorUtils.BlendColors(Color.Transparent, ks_color, getKSEffectValue()));
                }
            }

            return(killstreak_layer);
        }
        public override EffectLayer Render(IGameState state)
        {
            EffectLayer respawn_layer = new EffectLayer("Dota 2 - Respawn");

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

                if (dota2state.Player.Team != PlayerTeam.Undefined && dota2state.Player.Team != PlayerTeam.None && !dota2state.Hero.IsAlive)
                {
                    double percent = (dota2state.Hero.SecondsToRespawn > 5 ? 0.0 : 1.0 - (dota2state.Hero.SecondsToRespawn / 5.0));

                    respawn_layer.Fill(Utils.ColorUtils.BlendColors(Color.Transparent, Properties.BackgroundColor, percent));

                    respawn_layer.PercentEffect(Properties.RespawningColor,
                                                Properties.RespawnColor,
                                                Properties.Sequence,
                                                percent,
                                                1.0,
                                                PercentEffectType.AllAtOnce);
                }
            }

            return(respawn_layer);
        }
예제 #4
0
        public override EffectLayer Render(IGameState gamestate)
        {
            EffectLayer layer = new EffectLayer("Minecraft Burning Layer");

            // Render nothing if invalid gamestate or player isn't on fire
            if (!(gamestate is GameState_Minecraft) || !(gamestate as GameState_Minecraft).Player.IsBurning)
            {
                return(layer);
            }

            // Set the background to red
            layer.Fill(Color.Red);

            // Add 3 particles every frame
            for (int i = 0; i < 3; i++)
            {
                CreateFireParticle();
            }

            // Render all particles
            foreach (var particle in particles)
            {
                particle.mix.Draw(layer.GetGraphics(), particle.time);
                particle.time += .1f;
            }

            // Remove any expired particles
            particles.RemoveAll(particle => particle.time >= 1);

            return(layer);
        }
예제 #5
0
        public override EffectLayer Render(IGameState gamestate)
        {
            var currentChampion = (gamestate as GSI.GameState_LoL)?.Player.Champion ?? Champion.None;

            if (!Properties.ChampionColors.TryGetValue(currentChampion, out var currentColor))
            {
                currentColor = Color.Black;
            }

            //if the player changes champion
            //or if the color is adjusted in the UI
            //or if the canvas size changes due to the layout being changed
            if (currentChampion != lastChampion || currentColor != lastColor ||
                lastWidth != Effects.canvas_width || lastHeight != Effects.canvas_height)
            {
                lastChampion = currentChampion;
                lastColor    = currentColor;
                lastHeight   = Effects.canvas_height;
                lastWidth    = Effects.canvas_width;
                layer.Fill(lastColor);
                //then we fill the layer again
            }
            //otherwise, we can just return the same layer as it's mostly static
            return(layer);
        }
예제 #6
0
        public override void UpdateLights(EffectFrame frame)
        {
            Queue <EffectLayer> layers = new Queue <EffectLayer>();

            foreach (var layer in this.Application.Profile.Layers.Reverse().ToArray())
            {
                if (layer.Enabled && layer.LogicPass)
                {
                    layers.Enqueue(layer.Render(_game_state));
                }
            }

            layers.Enqueue(new EffectLayer("Color Zones").DrawColorZones((this.Application.Profile as DesktopProfile).lighting_areas.ToArray()));

            //Scripts before interactive and shortcut assistant layers
            //ProfilesManager.DesktopProfile.UpdateEffectScripts(layers);

            if (Global.Configuration.time_based_dimming_enabled)
            {
                if (
                    Utils.Time.IsCurrentTimeBetween(Global.Configuration.time_based_dimming_start_hour, Global.Configuration.time_based_dimming_end_hour)
                    )
                {
                    layers.Clear();

                    EffectLayer time_based_dim_layer = new EffectLayer("Time Based Dim");
                    time_based_dim_layer.Fill(Color.Black);

                    layers.Enqueue(time_based_dim_layer);
                }
            }

            frame.AddLayers(layers.ToArray());
        }
예제 #7
0
        public override EffectLayer Render(IGameState state)
        {
            EffectLayer states_layer = new EffectLayer("Payday 2 - States");

            if (state is GameState_PD2)
            {
                GameState_PD2 pd2state = (GameState_PD2)state;

                if (pd2state.Game.State == GameStates.Ingame)
                {
                    if (pd2state.LocalPlayer.State == PlayerState.Incapacitated || pd2state.LocalPlayer.State == PlayerState.Bleed_out || pd2state.LocalPlayer.State == PlayerState.Fatal)
                    {
                        int incapAlpha = (int)(pd2state.LocalPlayer.DownTime > 10 ? 0 : 255 * (1.0D - (double)pd2state.LocalPlayer.DownTime / 10.0D));

                        if (incapAlpha > 255)
                        {
                            incapAlpha = 255;
                        }
                        else if (incapAlpha < 0)
                        {
                            incapAlpha = 0;
                        }

                        Color incapColor = Color.FromArgb(incapAlpha, Properties.DownedColor);

                        states_layer.Fill(incapColor).Set(Devices.DeviceKeys.Peripheral, incapColor);
                    }
                    else if (pd2state.LocalPlayer.State == PlayerState.Arrested)
                    {
                        states_layer.Fill(Properties.ArrestedColor).Set(Devices.DeviceKeys.Peripheral, Properties.ArrestedColor);
                    }

                    if (pd2state.LocalPlayer.IsSwanSong && Properties.ShowSwanSong)
                    {
                        double blend_percent = Math.Pow(Math.Cos((Utils.Time.GetMillisecondsSinceEpoch() % 1300L) / 1300.0D * Properties.SwanSongSpeedMultiplier * 2.0D * Math.PI), 2.0D);

                        Color swansongColor = Utils.ColorUtils.MultiplyColorByScalar(Properties.SwanSongColor, blend_percent);

                        EffectLayer swansong_layer = new EffectLayer("Payday 2 - Swansong", swansongColor).Set(Devices.DeviceKeys.Peripheral, swansongColor);

                        states_layer += swansong_layer;
                    }
                }
            }

            return(states_layer);
        }
예제 #8
0
 private void BgFadeOut(EffectLayer animation_layer)
 {
     if (!(layerFadeState > 0))
     {
         return;
     }
     layerFadeState = Math.Max(0, layerFadeState - 0.03f);
     animation_layer.Fill(ColorUtils.BlendColors(Color.Empty, Color.Black, layerFadeState));
 }
        public override EffectLayer Render(IGameState gamestate)
        {
            var layer = new EffectLayer("FFXIV - Action Layer");

            layer.Fill(Color.Transparent);
            if (gamestate is GameState_FFXIV ffxiv)
            {
                var keybinds     = ffxiv.KeyBinds.ToList();
                var recordedKeys = Global.InputEvents;
                var modif        = new List <DeviceKeys>();
                if (recordedKeys.Alt)
                {
                    modif.AddRange(new [] { DeviceKeys.LEFT_ALT, DeviceKeys.LEFT_SHIFT });
                }
                if (recordedKeys.Control)
                {
                    modif.AddRange(new [] { DeviceKeys.LEFT_CONTROL, DeviceKeys.RIGHT_CONTROL });
                }
                if (recordedKeys.Shift)
                {
                    modif.AddRange(new [] { DeviceKeys.LEFT_SHIFT, DeviceKeys.RIGHT_SHIFT });
                }
                if (!recordedKeys.Shift && !recordedKeys.Control && !recordedKeys.Alt)
                {
                    modif.AddRange(new [] { DeviceKeys.NONE });
                }
                if (keybinds.Any() && (!prevKey.Any() || !keybinds.All(t => prevKey.Contains(t)) || !prevDevice.Any() || !modif.All(t => prevDevice.Contains(t))))
                {
                    var modifs = new List <DeviceKeys>();
                    foreach (var keyBind in keybinds.Where(t => t.Key != DeviceKeys.NONE && t.KeyMod.All(f => modif.Contains(f)) && (!modif.Any() || modif.All(f => t.KeyMod.Contains(f))) && (!Properties.Ignore || !t.Command.Contains("PERFORMANCE_MODE"))))
                    {
                        layer.Set(keyBind.Key, Properties.PrimaryColor);
                        if (keyBind.KeyMod[0] != DeviceKeys.NONE)
                        {
                            modifs.AddRange(keyBind.KeyMod);
                        }
                    }
                    layer.Set(modifs.ToArray(), Properties.PrimaryColor);
                    prevKey    = keybinds;
                    prevDevice = modif;
                }
                else
                {
                    layer = prev;
                }
            }
            else
            {
                layer = prev;
            }
            prev = layer;
            return(layer);
        }
예제 #10
0
        public override EffectLayer Render(IGameState state)
        {
            EffectLayer bg_layer = new EffectLayer("Elite: Dangerous - Background");

            GameState_EliteDangerous gameState = state as GameState_EliteDangerous;

            Color combat_bg_color = gameState.Status.IsFlagSet(Flag.HUD_DISCOVERY_MODE) ? this.Properties.DiscoveryModeColor : this.Properties.CombatModeColor;

            bg_layer.Fill(combat_bg_color);

            return(bg_layer);
        }
예제 #11
0
        public override EffectLayer Render(IGameState state)
        {
            EffectLayer bg_layer = new EffectLayer("Dota 2 - Background");

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

                if (dota2state.Previously.Hero.HealthPercent == 0 && dota2state.Hero.HealthPercent == 100 && !dota2state.Previously.Hero.IsAlive && dota2state.Hero.IsAlive)
                {
                    isDimming = false;
                    dim_bg_at = dota2state.Map.GameTime + (Global.Configuration.ApplicationProfiles["Dota 2"].Settings as Dota2Settings).bg_dim_after;
                    dim_value = 1.0;
                }


                Color bg_color = this.Properties.DefaultColor;

                switch (dota2state.Player.Team)
                {
                case PlayerTeam.Dire:
                    bg_color = this.Properties.DireColor;
                    break;

                case PlayerTeam.Radiant:
                    bg_color = this.Properties.RadiantColor;
                    break;

                default:
                    break;
                }

                if (dota2state.Player.Team == PlayerTeam.Dire || dota2state.Player.Team == PlayerTeam.Radiant)
                {
                    if (dim_bg_at <= dota2state.Map.GameTime || !dota2state.Hero.IsAlive)
                    {
                        isDimming = true;
                        bg_color  = Utils.ColorUtils.MultiplyColorByScalar(bg_color, getDimmingValue());
                    }
                    else
                    {
                        isDimming = false;
                        dim_value = 1.0;
                    }
                }

                bg_layer.Fill(bg_color);
            }

            return(bg_layer);
        }
예제 #12
0
        public override EffectLayer Render(IGameState state)
        {
            EffectLayer bg_layer = new EffectLayer("CSGO - Background");

            if (state is GameState_CSGO)
            {
                GameState_CSGO csgostate = state as GameState_CSGO;

                if (csgostate.Player.State.Health == 100 && ((csgostate.Previously.Player.State.Health > -1 && csgostate.Previously.Player.State.Health < 100) || (csgostate.Round.WinTeam == RoundWinTeam.Undefined && csgostate.Previously.Round.WinTeam != RoundWinTeam.Undefined)) && csgostate.Provider.SteamID.Equals(csgostate.Player.SteamID))
                {
                    isDimming = false;
                    dim_bg_at = Utils.Time.GetMillisecondsSinceEpoch() + (Application.Profile as CSGOProfile).bg_dim_after * 1000L;
                    dim_value = 1.0;
                }


                Color bg_color = this.Properties.DefaultColor;

                switch (csgostate.Player.Team)
                {
                case PlayerTeam.T:
                    bg_color = this.Properties.TColor;
                    break;

                case PlayerTeam.CT:
                    bg_color = this.Properties.CTColor;
                    break;

                default:
                    break;
                }

                if (csgostate.Player.Team == PlayerTeam.CT || csgostate.Player.Team == PlayerTeam.T)
                {
                    if (dim_bg_at <= Utils.Time.GetMillisecondsSinceEpoch() || csgostate.Player.State.Health == 0)
                    {
                        isDimming = true;
                        bg_color  = Utils.ColorUtils.MultiplyColorByScalar(bg_color, getDimmingValue());
                    }
                    else
                    {
                        isDimming = false;
                        dim_value = 1.0;
                    }
                }

                bg_layer.Fill(bg_color);
            }

            return(bg_layer);
        }
예제 #13
0
        public override EffectLayer Render(IGameState state)
        {
            EffectLayer effectLayer = new EffectLayer("CSGO - Death Effect");

            if (state is GameState_CSGO)
            {
                GameState_CSGO gameState  = state as GameState_CSGO;
                Color          deathColor = this.Properties.DeathColor;

                // Confirm if CS:GO Player is correct
                if (gameState.Provider.SteamID.Equals(gameState.Player.SteamID))
                {
                    // Are they dead?
                    if (!isDead && gameState.Player.State.Health <= 0 && gameState.Previously.Player.State.Health > 0)
                    {
                        isDead = true;

                        fadeAlpha   = 255;
                        fadeStartAt = Utils.Time.GetMillisecondsSinceEpoch() + (long)(this.Properties.FadeOutAfter * 1000D);
                    }
                    else if (gameState.Player.State.Health > 0)
                    {
                        isDead = false;
                        return(effectLayer);
                    }

                    // If so...
                    if (isDead)
                    {
                        Global.logger.Info("IsDead");
                        if (fadeStartAt <= Utils.Time.GetMillisecondsSinceEpoch())
                        {
                            int fadeAlpha = getFadeAlpha();
                            Global.logger.Info(fadeAlpha);

                            deathColor = Color.FromArgb(fadeAlpha, deathColor.R, deathColor.G, deathColor.B);

                            if (fadeAlpha == 0)
                            {
                                isDead = false;
                            }
                        }

                        effectLayer.Fill(deathColor);
                    }
                }
            }

            return(effectLayer);
        }
        public override EffectLayer Render(IGameState gamestate)
        {
            var layer = new EffectLayer("FFXIV - Action Layer");

            layer.Fill(Color.Transparent);
            if (gamestate is GameState_FFXIV ffxiv)
            {
                lock (ffxiv.Actions)
                {
                    var modif = getModifs();
                    if (ffxiv.Actions.Any() && (Math.Abs(ffxiv.Player.CastingPercentage - prevCastPercent) > 0 || !prevActions.Any() || !ffxiv.Actions.All(t => prevActions.Any(f => f.Equals(t))) || !prevDevice.Any() || !modif.All(t => prevDevice.Contains(t))))
                    {
                        layer.Set(ffxiv.Actions.Where(t => t.Key != DeviceKeys.NONE).Select(t => t.Key).ToArray(), Properties.NotAvailable);
                        foreach (var ffxivAction in ffxiv.Actions.Where(t => modif.All(f => f(t)) && t.Key != DeviceKeys.NONE))
                        {
                            layer.Set(ffxivAction.Key, ColorUtils.MultiplyColorByScalar(Properties.PrimaryColor, ffxivAction.GetCoolDownPrecent(ffxiv)));
                            if (ffxivAction.IsProcOrCombo)
                            {
                                layer.Set(ffxivAction.Key, ColorUtils.MultiplyColorByScalar(Properties.Combo, ffxivAction.GetCoolDownPrecent(ffxiv)));
                            }
                            if (!ffxivAction.InRange)
                            {
                                layer.Set(ffxivAction.Key, ColorUtils.MultiplyColorByScalar(Properties.OutOfRange, ffxivAction.GetCoolDownPrecent(ffxiv)));
                            }
                            if (!ffxivAction.IsAvailable)
                            {
                                layer.Set(ffxivAction.Key, Properties.NotAvailable);
                            }
                        }
                        setModifKeys(layer, ffxiv.Actions.Where(t => t.IsCtrl).ToArray(), new [] { DeviceKeys.LEFT_CONTROL, DeviceKeys.RIGHT_CONTROL }, ffxiv);
                        setModifKeys(layer, ffxiv.Actions.Where(t => t.IsShift).ToArray(), new [] { DeviceKeys.LEFT_SHIFT, DeviceKeys.RIGHT_SHIFT }, ffxiv);
                        setModifKeys(layer, ffxiv.Actions.Where(t => t.IsAlt).ToArray(), new [] { DeviceKeys.LEFT_ALT, DeviceKeys.RIGHT_ALT }, ffxiv);
                        prevActions     = ffxiv.Actions.ToList();
                        prevDevice      = modif;
                        prevCastPercent = ffxiv.Player.CastingPercentage;
                    }
                    else
                    {
                        layer = prev;
                    }
                }
            }
            else
            {
                layer = prev;
            }
            prev = layer;
            return(layer);
        }
예제 #15
0
        public override EffectLayer Render(IGameState gamestate)
        {
            EffectLayer sc_assistant_layer = new EffectLayer("Shortcut Assistant");

            Keys[] heldKeys = Global.InputEvents.PressedKeys;



            Tree <Keys> _childKeys = Properties.ShortcutKeysTree;

            foreach (var key in heldKeys)
            {
                if (_childKeys != null)
                {
                    _childKeys = _childKeys.ContainsItem(Properties.MergeModifierKey ? KeyUtils.GetStandardKey(key) : key);
                }
            }

            if (_childKeys != null && _childKeys.Item != Keys.None)
            {
                Keys[] shortcutKeys;

                if (Properties.PresentationType == ShortcutAssistantPresentationType.ProgressiveSuggestion)
                {
                    shortcutKeys = _childKeys.GetChildren();
                }
                else
                {
                    shortcutKeys = _childKeys.GetAllChildren();
                }

                if (shortcutKeys.Length > 0)
                {
                    if (Properties.DimBackground)
                    {
                        sc_assistant_layer.Fill(Properties.DimColor);
                    }

                    sc_assistant_layer.Set(Utils.KeyUtils.GetDeviceKeys(shortcutKeys, true, !Console.NumberLock), Properties.PrimaryColor);
                    sc_assistant_layer.Set(Utils.KeyUtils.GetDeviceKeys(heldKeys, true), Properties.PrimaryColor);
                }
            }

            return(sc_assistant_layer);
        }
예제 #16
0
        public override EffectLayer Render(IGameState state)
        {
            EffectLayer flashed_layer = new EffectLayer("CSGO - Flashed");

            if (state is GameState_CSGO)
            {
                GameState_CSGO csgostate = state as GameState_CSGO;

                //Update Flashed
                if (csgostate.Player.State.Flashed > 0)
                {
                    Color flash_color = Color.FromArgb(csgostate.Player.State.Flashed, Properties.FlashbangColor);

                    flashed_layer.Fill(flash_color);
                }
            }

            return(flashed_layer);
        }
예제 #17
0
        public override EffectLayer Render(IGameState state)
        {
            EffectLayer flashed_layer = new EffectLayer("Payday 2 - Flashed");

            if (state is GameState_PD2)
            {
                GameState_PD2 pd2state = state as GameState_PD2;

                //Update Flashed
                if (pd2state.Game.State == GameStates.Ingame && pd2state.LocalPlayer.FlashAmount > 0)
                {
                    Color flash_color = Utils.ColorUtils.MultiplyColorByScalar(Properties.FlashbangColor, pd2state.LocalPlayer.FlashAmount);

                    flashed_layer.Fill(flash_color);
                }
            }

            return(flashed_layer);
        }
예제 #18
0
        public override EffectLayer Render(IGameState state)
        {
            EffectLayer bg_layer = new EffectLayer("Witcher3 - Background");

            if (state is GameState_Witcher3)
            {
                GameState_Witcher3 Witcher3state = state as GameState_Witcher3;

                Color bg_color = this.Properties.DefaultColor;

                switch (Witcher3state.Player.ActiveSign)
                {
                case WitcherSign.Aard:
                    bg_color = this.Properties.AardColor;
                    break;

                case WitcherSign.Igni:
                    bg_color = this.Properties.IgniColor;
                    break;

                case WitcherSign.Quen:
                    bg_color = this.Properties.QuenColor;
                    break;

                case WitcherSign.Yrden:
                    bg_color = this.Properties.YrdenColor;
                    break;

                case WitcherSign.Axii:
                    bg_color = this.Properties.AxiiColor;
                    break;

                case WitcherSign.None:
                    bg_color = Properties.DefaultColor;
                    break;
                }
                bg_layer.Fill(bg_color);
            }

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

            //Get current color
            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);

            if (Properties.FillEntireKeyboard)
            {
                gradient_layer.Fill(selected_color);
            }
            else
            {
                gradient_layer.Set(Properties.Sequence, selected_color);
            }

            return(gradient_layer);
        }
예제 #20
0
        public override void UpdateLights(EffectFrame frame)
        {
            var layers = new Queue <EffectLayer>(Application.Profile.Layers.Where(l => l.Enabled).Reverse().Select(l => l.Render(_game_state)));

            //Scripts before interactive and shortcut assistant layers
            //ProfilesManager.DesktopProfile.UpdateEffectScripts(layers);

            if (Global.Configuration.TimeBasedDimmingEnabled)
            {
                if (Utils.Time.IsCurrentTimeBetween(Global.Configuration.TimeBasedDimmingStartHour, Global.Configuration.TimeBasedDimmingEndHour))
                {
                    layers.Clear();

                    EffectLayer time_based_dim_layer = new EffectLayer("Time Based Dim");
                    time_based_dim_layer.Fill(Color.Black);

                    layers.Enqueue(time_based_dim_layer);
                }
            }

            frame.AddLayers(layers.ToArray());
        }
예제 #21
0
        public override EffectLayer Render(IGameState gamestate)
        {
            EffectLayer layer = new EffectLayer("Minecraft Key Conflict Layer");

            if (gamestate is GameState_Minecraft && (gamestate as GameState_Minecraft).Game.ControlsGuiOpen)
            {
                layer.Fill(Color.Black); // Hide any other layers behind this one
                // Set all keys in use by any binding to be the no-conflict colour
                foreach (var kb in ((GameState_Minecraft)gamestate).Game.KeyBindings)
                {
                    if (kb != null)
                    {
                        layer.Set(kb.AffectedKeys, Properties.PrimaryColor);
                    }
                }

                // Override the keys for all conflicting keys
                foreach (var kvp in CalculateConflicts((GameState_Minecraft)gamestate))
                {
                    layer.Set(kvp.Key, kvp.Value ? Properties.TertiaryColor : Properties.SecondaryColor);
                }
            }
            return(layer);
        }
예제 #22
0
        public override void UpdateLights(EffectFrame frame)
        {
            previoustime = currenttime;
            currenttime  = Utils.Time.GetMillisecondsSinceEpoch();

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

            float time = (float)Math.Pow(Math.Sin(1.0D * (internalcounter++ / 10.0f)), 2.0d);

            EffectLayer cz_layer = new EffectLayer("Color Zones");

            cz_layer.DrawColorZones((Global.Configuration.desktop_profile.Settings as DesktopSettings).lighting_areas.ToArray());
            layers.Enqueue(cz_layer);

            if ((Global.Configuration.desktop_profile.Settings as DesktopSettings).cpu_usage_enabled)
            {
                EffectLayer cpu = new EffectLayer("CPU");

                if (currentCPUValue - previousCPUValue > 0.0f && transitionalCPUValue < currentCPUValue)
                {
                    transitionalCPUValue += (currentCPUValue - previousCPUValue) / 100.0f;
                }
                else if (currentCPUValue - previousCPUValue < 0.0f && transitionalCPUValue > currentCPUValue)
                {
                    transitionalCPUValue -= (previousCPUValue - currentCPUValue) / 100.0f;
                }
                else if (currentCPUValue - previousCPUValue == 0.0f && transitionalCPUValue != currentCPUValue)
                {
                    transitionalCPUValue = currentCPUValue;
                }

                Color cpu_used = (Global.Configuration.desktop_profile.Settings as DesktopSettings).cpu_used_color;
                Color cpu_free = (Global.Configuration.desktop_profile.Settings as DesktopSettings).cpu_free_color;

                if ((Global.Configuration.desktop_profile.Settings as DesktopSettings).cpu_free_color_transparent)
                {
                    cpu_free = Color.FromArgb(0, cpu_used);
                }

                cpu.PercentEffect(cpu_used, cpu_free, (Global.Configuration.desktop_profile.Settings as DesktopSettings).cpu_sequence, transitionalCPUValue, 100.0f, (Global.Configuration.desktop_profile.Settings as DesktopSettings).cpu_usage_effect_type);

                layers.Enqueue(cpu);
            }

            if ((Global.Configuration.desktop_profile.Settings as DesktopSettings).ram_usage_enabled)
            {
                EffectLayer memory = new EffectLayer("Memory");

                double percentFree     = ((double)memory_Available / (double)memory_Total);
                double percentOccupied = 1.0D - percentFree;

                Color ram_used = (Global.Configuration.desktop_profile.Settings as DesktopSettings).ram_used_color;
                Color ram_free = (Global.Configuration.desktop_profile.Settings as DesktopSettings).ram_free_color;

                if ((Global.Configuration.desktop_profile.Settings as DesktopSettings).ram_free_color_transparent)
                {
                    ram_free = Color.FromArgb(0, ram_used);
                }

                memory.PercentEffect(ram_used, ram_free, (Global.Configuration.desktop_profile.Settings as DesktopSettings).ram_sequence, percentOccupied, 1.0D, (Global.Configuration.desktop_profile.Settings as DesktopSettings).ram_usage_effect_type);

                layers.Enqueue(memory);
            }

            //Scripts before interactive and shortcut assistant layers
            Global.Configuration.desktop_profile.UpdateEffectScripts(layers);

            EffectLayer interactive_layer = new EffectLayer("Interactive Effects");

            foreach (var input in input_list.ToArray())
            {
                if (input == null)
                {
                    continue;
                }

                try
                {
                    if (input.type == input_item.input_type.Spectrum)
                    {
                        float transition_value = input.progress / Effects.canvas_width;

                        if (transition_value > 1.0f)
                        {
                            continue;
                        }

                        Color color = input.spectrum.GetColorAt(transition_value);

                        interactive_layer.Set(input.key, color);
                    }
                    else if (input.type == input_item.input_type.AnimationMix)
                    {
                        float time_value = input.progress / Effects.canvas_width;

                        if (time_value > 1.0f)
                        {
                            continue;
                        }

                        input.animation.Draw(interactive_layer.GetGraphics(), time_value);
                    }
                }
                catch (Exception exc)
                {
                    Global.logger.LogLine("Interative layer exception, " + exc, Logging_Level.Error);
                }
            }

            for (int x = input_list.Count - 1; x >= 0; x--)
            {
                try
                {
                    if (input_list[x].progress > Effects.canvas_width)
                    {
                        input_list.RemoveAt(x);
                    }
                    else
                    {
                        float trans_added = ((Global.Configuration.desktop_profile.Settings as DesktopSettings).interactive_effect_speed * (getDeltaTime() * 5.0f));
                        input_list[x].progress += trans_added;
                    }
                }
                catch (Exception exc)
                {
                    Global.logger.LogLine("Interative layer exception, " + exc, Logging_Level.Error);
                }
            }

            layers.Enqueue(interactive_layer);

            if (Global.Configuration.time_based_dimming_enabled)
            {
                if (
                    Utils.Time.IsCurrentTimeBetween(Global.Configuration.time_based_dimming_start_hour, Global.Configuration.time_based_dimming_end_hour)
                    )
                {
                    layers.Clear();

                    EffectLayer time_based_dim_layer = new EffectLayer("Time Based Dim");
                    time_based_dim_layer.Fill(Color.Black);

                    layers.Enqueue(time_based_dim_layer);
                }
            }

            EffectLayer sc_assistant_layer = new EffectLayer("Shortcut Assistant");

            if ((Global.Configuration.desktop_profile.Settings as DesktopSettings).shortcuts_assistant_enabled)
            {
                if (Global.held_modified == Keys.LControlKey || Global.held_modified == Keys.RControlKey)
                {
                    if ((Global.Configuration.desktop_profile.Settings as DesktopSettings).shortcuts_assistant_bim_bg)
                    {
                        sc_assistant_layer.Fill(Color.FromArgb(169, 0, 0, 0));
                    }

                    if (Global.held_modified == Keys.LControlKey)
                    {
                        sc_assistant_layer.Set(Devices.DeviceKeys.LEFT_CONTROL, (Global.Configuration.desktop_profile.Settings as DesktopSettings).ctrl_key_color);
                    }
                    else
                    {
                        sc_assistant_layer.Set(Devices.DeviceKeys.RIGHT_CONTROL, (Global.Configuration.desktop_profile.Settings as DesktopSettings).ctrl_key_color);
                    }
                    sc_assistant_layer.Set((Global.Configuration.desktop_profile.Settings as DesktopSettings).ctrl_key_sequence, (Global.Configuration.desktop_profile.Settings as DesktopSettings).ctrl_key_color);
                }
                else if (Global.held_modified == Keys.LMenu || Global.held_modified == Keys.RMenu)
                {
                    if ((Global.Configuration.desktop_profile.Settings as DesktopSettings).shortcuts_assistant_bim_bg)
                    {
                        sc_assistant_layer.Fill(Color.FromArgb(169, 0, 0, 0));
                    }

                    if (Global.held_modified == Keys.LMenu)
                    {
                        sc_assistant_layer.Set(Devices.DeviceKeys.LEFT_ALT, (Global.Configuration.desktop_profile.Settings as DesktopSettings).alt_key_color);
                    }
                    else
                    {
                        sc_assistant_layer.Set(Devices.DeviceKeys.RIGHT_ALT, (Global.Configuration.desktop_profile.Settings as DesktopSettings).alt_key_color);
                    }
                    sc_assistant_layer.Set((Global.Configuration.desktop_profile.Settings as DesktopSettings).alt_key_sequence, (Global.Configuration.desktop_profile.Settings as DesktopSettings).alt_key_color);
                }
                else if (Global.held_modified == Keys.LWin || Global.held_modified == Keys.RWin)
                {
                    if ((Global.Configuration.desktop_profile.Settings as DesktopSettings).shortcuts_assistant_bim_bg)
                    {
                        sc_assistant_layer.Fill(Color.FromArgb(169, 0, 0, 0));
                    }

                    if (Global.held_modified == Keys.LWin)
                    {
                        sc_assistant_layer.Set(Devices.DeviceKeys.LEFT_WINDOWS, (Global.Configuration.desktop_profile.Settings as DesktopSettings).win_key_color);
                    }
                    else
                    {
                        sc_assistant_layer.Set(Devices.DeviceKeys.RIGHT_WINDOWS, (Global.Configuration.desktop_profile.Settings as DesktopSettings).win_key_color);
                    }
                    sc_assistant_layer.Set((Global.Configuration.desktop_profile.Settings as DesktopSettings).win_key_sequence, (Global.Configuration.desktop_profile.Settings as DesktopSettings).win_key_color);
                }
            }
            layers.Enqueue(sc_assistant_layer);

            frame.AddLayers(layers.ToArray());
        }
예제 #23
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;
        }
예제 #24
0
 public void SetEffect(EffectLayer layer, long time)
 {
     layer.Fill(GetCurrentColor(time));
 }
예제 #25
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;

            default:
                break;
            }

            frame.AddOverlayLayers(layers.ToArray());
        }
예제 #26
0
        public override EffectLayer Render(IGameState state)
        {
            previoustime = currenttime;
            currenttime  = Utils.Time.GetMillisecondsSinceEpoch();

            EffectLayer  effectLayer  = new EffectLayer("CSGO - Winning Team Effect");
            AnimationMix animationMix = new AnimationMix();

            if (state is GameState_CSGO)
            {
                GameState_CSGO csgostate = state as GameState_CSGO;

                // Block animations after end of round
                if (csgostate.Map.Phase == MapPhase.Undefined || csgostate.Round.Phase != RoundPhase.Over)
                {
                    return(effectLayer);
                }

                Color color = Color.White;

                // Triggers directly after a team wins a round
                if (csgostate.Round.WinTeam != RoundWinTeam.Undefined && csgostate.Previously.Round.WinTeam == RoundWinTeam.Undefined)
                {
                    // Determine round or game winner
                    if (csgostate.Map.Phase == MapPhase.GameOver)
                    {
                        // End of match
                        int tScore  = csgostate.Map.TeamT.Score;
                        int ctScore = csgostate.Map.TeamCT.Score;

                        if (tScore > ctScore)
                        {
                            color = Properties.TColor;
                        }
                        else if (ctScore > tScore)
                        {
                            color = Properties.CTColor;
                        }
                    }
                    else
                    {
                        // End of round
                        if (csgostate.Round.WinTeam == RoundWinTeam.T)
                        {
                            color = Properties.TColor;
                        }
                        if (csgostate.Round.WinTeam == RoundWinTeam.CT)
                        {
                            color = Properties.CTColor;
                        }
                    }

                    this.SetTracks(color);
                    animationMix.Clear();
                    showAnimation = true;
                }

                if (showAnimation)
                {
                    animationMix = new AnimationMix(tracks);

                    effectLayer.Fill(color);
                    animationMix.Draw(effectLayer.GetGraphics(), winningTeamEffect_Keyframe);
                    winningTeamEffect_Keyframe += (currenttime - previoustime) / 1000.0f;

                    if (winningTeamEffect_Keyframe >= winningTeamEffect_AnimationTime)
                    {
                        showAnimation = false;
                        winningTeamEffect_Keyframe = 0;
                    }
                }
            }

            return(effectLayer);
        }
예제 #27
0
        public override EffectLayer Render(IGameState gamestate)
        {
            MMDevice current_device = audio_device_enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);

            if (default_device == null || default_device.ID != current_device.ID)
            {
                UpdateAudioCapture();
            }

            float[] freqs = Properties.Frequencies.ToArray(); //Defined Frequencies

            double[] freq_results = new double[freqs.Length];

            if (previous_freq_results == null || previous_freq_results.Length < freqs.Length)
            {
                previous_freq_results = new float[freqs.Length];
            }

            //Maintain local copies of fft, to prevent data overwrite
            Complex[] _local_fft          = new List <Complex>(_ffts).ToArray();
            Complex[] _local_fft_previous = new List <Complex>(_ffts_prev).ToArray();

            EffectLayer equalizer_layer = new EffectLayer();

            if (Properties.DimBackgroundOnSound)
            {
                bool hasSound = false;
                foreach (var bin in _local_fft)
                {
                    if (bin.X > 0.0005 || bin.X < -0.0005)
                    {
                        hasSound = true;
                        break;
                    }
                }

                if (hasSound)
                {
                    equalizer_layer.Fill(Properties.DimColor);
                }
            }

            using (Graphics g = equalizer_layer.GetGraphics())
            {
                int wave_step_amount = _local_fft.Length / Effects.canvas_width;

                switch (Properties.EQType)
                {
                case EqualizerType.Waveform:
                    for (int x = 0; x < Effects.canvas_width; x++)
                    {
                        float fft_val = _local_fft.Length > x * wave_step_amount ? _local_fft[x * wave_step_amount].X : 0.0f;

                        Brush brush = GetBrush(fft_val, x, Effects.canvas_width);

                        g.DrawLine(new Pen(brush), x, Effects.canvas_height_center, x, Effects.canvas_height_center - fft_val * 500.0f);
                    }
                    break;

                case EqualizerType.Waveform_Bottom:
                    for (int x = 0; x < Effects.canvas_width; x++)
                    {
                        float fft_val = _local_fft.Length > x * wave_step_amount ? _local_fft[x * wave_step_amount].X : 0.0f;

                        Brush brush = GetBrush(fft_val, x, Effects.canvas_width);

                        g.DrawLine(new Pen(brush), x, Effects.canvas_height, x, Effects.canvas_height - Math.Abs(fft_val) * 1000.0f);
                    }
                    break;

                case EqualizerType.PowerBars:

                    //Perform FFT again to get frequencies
                    FastFourierTransform.FFT(false, (int)Math.Log(fftLength, 2.0), _local_fft);

                    while (flux_array.Count < freqs.Length)
                    {
                        flux_array.Add(0.0f);
                    }

                    int startF = 0;
                    int endF   = 0;

                    float threshhold = 300.0f;

                    for (int x = 0; x < freqs.Length - 1; x++)
                    {
                        startF = freqToBin(freqs[x]);
                        endF   = freqToBin(freqs[x + 1]);

                        float flux = 0.0f;

                        for (int j = startF; j <= endF; j++)
                        {
                            float curr_fft = (float)Math.Sqrt(_local_fft[j].X * _local_fft[j].X + _local_fft[j].Y * _local_fft[j].Y);
                            float prev_fft = (float)Math.Sqrt(_local_fft_previous[j].X * _local_fft_previous[j].X + _local_fft_previous[j].Y * _local_fft_previous[j].Y);

                            float value     = curr_fft - prev_fft;
                            float flux_calc = (value + Math.Abs(value)) / 2;
                            if (flux < flux_calc)
                            {
                                flux = flux_calc;
                            }

                            flux = flux > threshhold ? 0.0f : flux;
                        }

                        flux_array[x] = flux;
                    }

                    //System.Diagnostics.Debug.WriteLine($"flux max: {flux_array.Max()}");

                    float bar_width = Effects.canvas_width / (float)(freqs.Length - 1);

                    for (int f_x = 0; f_x < freq_results.Length - 1; f_x++)
                    {
                        float fft_val = flux_array[f_x] / Properties.MaxAmplitude;

                        fft_val = Math.Min(1.0f, fft_val);

                        if (previous_freq_results[f_x] - fft_val > 0.10)
                        {
                            fft_val = previous_freq_results[f_x] - 0.15f;
                        }

                        float x      = f_x * bar_width;
                        float y      = Effects.canvas_height;
                        float width  = bar_width;
                        float height = fft_val * Effects.canvas_height;

                        previous_freq_results[f_x] = fft_val;

                        Brush brush = GetBrush(-(f_x % 2), f_x, freq_results.Length - 1);

                        g.FillRectangle(brush, x, y - height, width, height);
                    }

                    break;
                }
            }

            return(equalizer_layer);
        }
예제 #28
0
        public override void UpdateLights(EffectFrame frame)
        {
            Queue <EffectLayer> layers = new Queue <EffectLayer>();

            if ((Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).bg_color_enabled)
            {
                EffectLayer bg_layer = new EffectLayer("GTA 5 - Background");

                Color bg_color = (Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).bg_ambient;

                switch (curr_state)
                {
                case PlayerState.PlayingSP_Trevor:
                    bg_color = (Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).bg_trevor;
                    break;

                case PlayerState.PlayingSP_Franklin:
                    bg_color = (Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).bg_franklin;
                    break;

                case PlayerState.PlayingSP_Michael:
                    bg_color = (Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).bg_michael;
                    break;

                case PlayerState.PlayingSP_Chop:
                    bg_color = (Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).bg_chop;
                    break;

                case PlayerState.PlayingMP:
                    bg_color = (Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).bg_online;
                    break;

                case PlayerState.PlayingMP_Mission:
                    bg_color = (Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).bg_online_mission;
                    break;

                case PlayerState.PlayingMP_HeistFinale:
                    bg_color = (Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).bg_online_heistfinale;
                    break;

                case PlayerState.PlayingMP_Spectator:
                    bg_color = (Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).bg_online_spectator;
                    break;

                case PlayerState.PlayingRace_Gold:
                    bg_color = (Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).bg_race_gold;
                    break;

                case PlayerState.PlayingRace_Silver:
                    bg_color = (Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).bg_race_silver;
                    break;

                case PlayerState.PlayingRace_Bronze:
                    bg_color = (Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).bg_race_bronze;
                    break;

                default:
                    bg_color = (Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).bg_ambient;
                    break;
                }

                bg_layer.Fill(bg_color);

                if ((Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).bg_peripheral_use)
                {
                    bg_layer.Set(Devices.DeviceKeys.Peripheral, bg_color);
                }

                layers.Enqueue(bg_layer);
            }

            if ((Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).siren_enabled && have_cops)
            {
                EffectLayer sirens_layer = new EffectLayer("GTA 5 - Police Sirens");

                Color lefts  = (Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).left_siren_color;
                Color rights = (Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).right_siren_color;

                KeySequence left_siren_ks  = (Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).left_siren_sequence;
                KeySequence right_siren_ks = (Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).right_siren_sequence;

                //Switch sirens
                switch ((Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).siren_type)
                {
                case GTA5_PoliceEffects.Alt_Full:
                    switch (siren_keyframe % 2)
                    {
                    case 1:
                        rights = lefts;
                        break;

                    default:
                        lefts = rights;
                        break;
                    }
                    siren_keyframe = siren_keyframe % 2;

                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).siren_peripheral_use)
                    {
                        sirens_layer.Set(Devices.DeviceKeys.Peripheral, lefts);
                    }
                    break;

                case GTA5_PoliceEffects.Alt_Half:
                    switch (siren_keyframe % 2)
                    {
                    case 1:
                        rights = lefts;
                        lefts  = Color.Black;

                        if ((Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).siren_peripheral_use)
                        {
                            sirens_layer.Set(Devices.DeviceKeys.Peripheral, rights);
                        }
                        break;

                    default:
                        lefts  = rights;
                        rights = Color.Black;

                        if ((Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).siren_peripheral_use)
                        {
                            sirens_layer.Set(Devices.DeviceKeys.Peripheral, lefts);
                        }
                        break;
                    }
                    siren_keyframe = siren_keyframe % 2;
                    break;

                case GTA5_PoliceEffects.Alt_Full_Blink:
                    switch (siren_keyframe % 4)
                    {
                    case 2:
                        rights = lefts;
                        break;

                    case 0:
                        lefts = rights;
                        break;

                    default:
                        lefts  = Color.Black;
                        rights = Color.Black;
                        break;
                    }
                    siren_keyframe = siren_keyframe % 4;

                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).siren_peripheral_use)
                    {
                        sirens_layer.Set(Devices.DeviceKeys.Peripheral, lefts);
                    }
                    break;

                case GTA5_PoliceEffects.Alt_Half_Blink:
                    switch (siren_keyframe % 8)
                    {
                    case 6:
                        rights = lefts;
                        lefts  = Color.Black;

                        if ((Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).siren_peripheral_use)
                        {
                            sirens_layer.Set(Devices.DeviceKeys.Peripheral, rights);
                        }
                        break;

                    case 4:
                        rights = lefts;
                        lefts  = Color.Black;

                        if ((Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).siren_peripheral_use)
                        {
                            sirens_layer.Set(Devices.DeviceKeys.Peripheral, rights);
                        }
                        break;

                    case 2:
                        lefts  = rights;
                        rights = Color.Black;

                        if ((Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).siren_peripheral_use)
                        {
                            sirens_layer.Set(Devices.DeviceKeys.Peripheral, lefts);
                        }
                        break;

                    case 0:
                        lefts  = rights;
                        rights = Color.Black;

                        if ((Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).siren_peripheral_use)
                        {
                            sirens_layer.Set(Devices.DeviceKeys.Peripheral, lefts);
                        }
                        break;

                    default:
                        rights = Color.Black;
                        lefts  = Color.Black;

                        if ((Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).siren_peripheral_use)
                        {
                            sirens_layer.Set(Devices.DeviceKeys.Peripheral, lefts);
                        }
                        break;
                    }
                    siren_keyframe = siren_keyframe % 8;
                    break;

                default:
                    switch (siren_keyframe % 2)
                    {
                    case 1:
                        Color tempc = rights;
                        rights = lefts;
                        lefts  = tempc;
                        break;

                    default:
                        break;
                    }
                    siren_keyframe = siren_keyframe % 2;

                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).siren_peripheral_use)
                    {
                        sirens_layer.Set(Devices.DeviceKeys.Peripheral, lefts);
                    }
                    break;
                }

                sirens_layer.Set(left_siren_ks, lefts);
                sirens_layer.Set(right_siren_ks, rights);

                layers.Enqueue(sirens_layer);
            }

            //ColorZones
            EffectLayer cz_layer = new EffectLayer("GTA 5 - Color Zones");

            cz_layer.DrawColorZones((Global.Configuration.ApplicationProfiles[profilename].Settings as GTA5Settings).lighting_areas.ToArray());
            layers.Enqueue(cz_layer);

            EffectLayer debug_layer = new EffectLayer("GTA 5 - Debug");

            if (special_mode == 16711939)
            {
                debug_layer.Set(Devices.DeviceKeys.SPACE, Color.Red);
            }
            else if (special_mode == 16775939)
            {
                debug_layer.Set(Devices.DeviceKeys.SPACE, Color.Blue);
            }

            layers.Enqueue(debug_layer);

            //Scripts
            Global.Configuration.ApplicationProfiles[profilename].UpdateEffectScripts(layers, _game_state);

            frame.AddLayers(layers.ToArray());
        }
예제 #29
0
        public override void UpdateLights(EffectFrame frame)
        {
            currenttime = Utils.Time.GetMillisecondsSinceEpoch();

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

            //update background
            if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).bg_enabled)
            {
                EffectLayer bg_layer = new EffectLayer("Payday 2 - Background");

                Color bg_color = (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).ambient_color;

                if ((level_phase == LevelPhase.Assault || level_phase == LevelPhase.Winters) && game_state == GameStates.Ingame)
                {
                    if (level_phase == LevelPhase.Assault)
                    {
                        bg_color = (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).assault_color;
                    }
                    else if (level_phase == LevelPhase.Winters)
                    {
                        bg_color = (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).winters_color;
                    }

                    double blend_percent = Math.Pow(Math.Sin(((currenttime % 1300L) / 1300.0D) * (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).assault_speed_mult * 2.0D * Math.PI), 2.0D);

                    bg_color = Utils.ColorUtils.BlendColors((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).assault_fade_color, bg_color, blend_percent);

                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).assault_animation_enabled)
                    {
                        Color effect_contours            = Color.FromArgb(200, Color.Black);
                        float animation_stage_yoffset    = 20.0f;
                        float animation_repeat_keyframes = 250.0f; //Effects.canvas_width * 2.0f;

                        /* Effect visual:
                         *
                         * / /  ----  / /
                         *
                         */

                        EffectColorFunction line1_col_func = new EffectColorFunction(
                            new EffectLine(-1f, Effects.canvas_width + assault_yoffset + animation_stage_yoffset),
                            new ColorSpectrum(effect_contours),
                            2);

                        EffectColorFunction line2_col_func = new EffectColorFunction(
                            new EffectLine(-1f, Effects.canvas_width + assault_yoffset + 9.0f + animation_stage_yoffset),
                            new ColorSpectrum(effect_contours),
                            2);

                        EffectColorFunction line3_col_func = new EffectColorFunction(
                            new EffectLine(new EffectPoint(Effects.canvas_width + assault_yoffset + 17.0f + animation_stage_yoffset, Effects.canvas_height / 2.0f), new EffectPoint(Effects.canvas_width + assault_yoffset + 34.0f + animation_stage_yoffset, Effects.canvas_height / 2.0f), true),
                            new ColorSpectrum(effect_contours),
                            6);

                        EffectColorFunction line4_col_func = new EffectColorFunction(
                            new EffectLine(-1f, Effects.canvas_width + assault_yoffset + 52.0f + animation_stage_yoffset),
                            new ColorSpectrum(effect_contours),
                            2);

                        EffectColorFunction line5_col_func = new EffectColorFunction(
                            new EffectLine(-1f, Effects.canvas_width + assault_yoffset + 61.0f + animation_stage_yoffset),
                            new ColorSpectrum(effect_contours),
                            2);

                        assault_yoffset -= 0.50f;
                        assault_yoffset  = assault_yoffset % animation_repeat_keyframes;

                        bg_layer.AddPostFunction(line1_col_func);
                        bg_layer.AddPostFunction(line2_col_func);
                        //bg_layer.AddPostFunction(line3_col_func);
                        bg_layer.AddPostFunction(line4_col_func);
                        bg_layer.AddPostFunction(line5_col_func);
                    }

                    bg_layer.Fill(bg_color);

                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).bg_peripheral_use)
                    {
                        bg_layer.Set(Devices.DeviceKeys.Peripheral, bg_color);
                    }
                }
                else if (level_phase == LevelPhase.Stealth && game_state == GameStates.Ingame)
                {
                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).bg_show_suspicion)
                    {
                        double percentSuspicious = ((double)suspicion_amount / (double)1.0);

                        ColorSpectrum suspicion_spec = new ColorSpectrum((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).low_suspicion_color, (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).high_suspicion_color);
                        suspicion_spec.SetColorAt(0.5f, (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).medium_suspicion_color);

                        Settings.KeySequence suspicionSequence = new Settings.KeySequence(new Settings.FreeFormObject(0, 0, 1.0f / (Effects.editor_to_canvas_width / Effects.canvas_width), 1.0f / (Effects.editor_to_canvas_height / Effects.canvas_height)));

                        bg_layer.PercentEffect(suspicion_spec, suspicionSequence, percentSuspicious, 1.0D, (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).suspicion_effect_type);

                        if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).bg_peripheral_use)
                        {
                            bg_layer.Set(Devices.DeviceKeys.Peripheral, suspicion_spec.GetColorAt((float)percentSuspicious));
                        }
                    }
                }
                else if (level_phase == LevelPhase.Point_of_no_return && game_state == GameStates.Ingame)
                {
                    ColorSpectrum no_return_spec = new ColorSpectrum(Color.Red, Color.Yellow);

                    Color no_return_color = no_return_spec.GetColorAt(no_return_flashamount);
                    no_return_flashamount -= 0.05f;

                    if (no_return_flashamount < 0.0f)
                    {
                        no_return_flashamount = 0.0f;
                    }

                    bg_layer.Fill(no_return_color);

                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).bg_peripheral_use)
                    {
                        bg_layer.Set(Devices.DeviceKeys.Peripheral, no_return_color);
                    }
                }
                else
                {
                    bg_layer.Fill(bg_color);

                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).bg_peripheral_use)
                    {
                        bg_layer.Set(Devices.DeviceKeys.Peripheral, bg_color);
                    }
                }

                layers.Enqueue(bg_layer);
            }

            if (game_state == GameStates.Ingame)
            {
                if (
                    player_state == PlayerState.Mask_Off ||
                    player_state == PlayerState.Standard ||
                    player_state == PlayerState.Jerry1 ||
                    player_state == PlayerState.Jerry2 ||
                    player_state == PlayerState.Tased ||
                    player_state == PlayerState.Bipod ||
                    player_state == PlayerState.Carry
                    )
                {
                    //Update Health
                    EffectLayer hpbar_layer = new EffectLayer("Payday 2 - HP Bar");
                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).health_enabled)
                    {
                        hpbar_layer.PercentEffect((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).healthy_color,
                                                  (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).hurt_color,
                                                  (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).health_sequence,
                                                  (double)health,
                                                  (double)health_max,
                                                  (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).health_effect_type);
                    }

                    layers.Enqueue(hpbar_layer);

                    //Update Health
                    EffectLayer ammobar_layer = new EffectLayer("Payday 2 - Ammo Bar");
                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).ammo_enabled)
                    {
                        hpbar_layer.PercentEffect((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).ammo_color,
                                                  (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).noammo_color,
                                                  (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).ammo_sequence,
                                                  (double)clip,
                                                  (double)clip_max,
                                                  (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).ammo_effect_type);
                    }

                    layers.Enqueue(ammobar_layer);
                }
                else if (player_state == PlayerState.Incapacitated || player_state == PlayerState.Bleed_out || player_state == PlayerState.Fatal)
                {
                    int incapAlpha = (int)(down_time > 10 ? 0 : 255 * (1.0D - (double)down_time / 10.0D));

                    if (incapAlpha > 255)
                    {
                        incapAlpha = 255;
                    }
                    else if (incapAlpha < 0)
                    {
                        incapAlpha = 0;
                    }

                    Color       incapColor  = Color.FromArgb(incapAlpha, (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).downed_color);
                    EffectLayer incap_layer = new EffectLayer("Payday 2 - Incapacitated", incapColor);
                    incap_layer.Set(Devices.DeviceKeys.Peripheral, incapColor);

                    layers.Enqueue(incap_layer);
                }
                else if (player_state == PlayerState.Arrested)
                {
                    Color       arrstedColor   = (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).arrested_color;
                    EffectLayer arrested_layer = new EffectLayer("Payday 2 - Arrested", arrstedColor);
                    arrested_layer.Set(Devices.DeviceKeys.Peripheral, arrstedColor);

                    layers.Enqueue(arrested_layer);
                }

                if (isSwanSong && (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).swansong_enabled)
                {
                    EffectLayer swansong_layer = new EffectLayer("Payday 2 - Swansong");

                    double blend_percent = Math.Pow(Math.Cos((currenttime % 1300L) / 1300.0D * (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).swansong_speed_mult * 2.0D * Math.PI), 2.0D);

                    Color swansongColor = Utils.ColorUtils.MultiplyColorByScalar((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).swansong_color, blend_percent);

                    swansong_layer.Fill(swansongColor);

                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).bg_peripheral_use)
                    {
                        swansong_layer.Set(Devices.DeviceKeys.Peripheral, swansongColor);
                    }

                    layers.Enqueue(swansong_layer);
                }

                //Update Flashed
                if (flashbang_amount > 0)
                {
                    EffectLayer flashed_layer = new EffectLayer("Payday 2 - Flashed");

                    Color flash_color = Utils.ColorUtils.MultiplyColorByScalar(Color.White, flashbang_amount);

                    flashed_layer.Fill(flash_color);

                    layers.Enqueue(flashed_layer);
                }
            }

            //ColorZones
            EffectLayer cz_layer = new EffectLayer("Payday 2 - Color Zones");

            cz_layer.DrawColorZones((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).lighting_areas.ToArray());
            layers.Enqueue(cz_layer);

            //Scripts
            Global.Configuration.ApplicationProfiles[profilename].UpdateEffectScripts(layers, _game_state);

            frame.AddLayers(layers.ToArray());

            lasttime = currenttime;
        }
예제 #30
0
        public override EffectLayer Render(IGameState gamestate)
        {
            try
            {
                //if (current_device != null)
                //current_device.Dispose();
                CheckForDeviceChange();

                // The system sound as a value between 0.0 and 1.0
                float system_sound_normalized = default_device.AudioEndpointVolume.MasterVolumeLevelScalar;

                // Scale the Maximum amplitude with the system sound if enabled, so that at 100% volume the max_amp is unchanged.
                // Replaces all Properties.MaxAmplitude calls with the scaled value
                float scaled_max_amplitude = Properties.MaxAmplitude * (Properties.ScaleWithSystemVolume ? system_sound_normalized : 1);

                float[] freqs = Properties.Frequencies.ToArray(); //Defined Frequencies

                double[] freq_results = new double[freqs.Length];

                if (previous_freq_results == null || previous_freq_results.Length < freqs.Length)
                {
                    previous_freq_results = new float[freqs.Length];
                }

                //Maintain local copies of fft, to prevent data overwrite
                Complex[] _local_fft          = new List <Complex>(_ffts).ToArray();
                Complex[] _local_fft_previous = new List <Complex>(_ffts_prev).ToArray();

                EffectLayer equalizer_layer = new EffectLayer();

                if (Properties.DimBackgroundOnSound)
                {
                    bool hasSound = false;
                    foreach (var bin in _local_fft)
                    {
                        if (bin.X > 0.0005 || bin.X < -0.0005)
                        {
                            hasSound = true;
                            break;
                        }
                    }

                    if (hasSound)
                    {
                        equalizer_layer.Fill(Properties.DimColor);
                    }
                }

                using (Graphics g = equalizer_layer.GetGraphics())
                {
                    int wave_step_amount = _local_fft.Length / Effects.canvas_width;

                    switch (Properties.EQType)
                    {
                    case EqualizerType.Waveform:
                        for (int x = 0; x < Effects.canvas_width; x++)
                        {
                            float fft_val = _local_fft.Length > x * wave_step_amount ? _local_fft[x * wave_step_amount].X : 0.0f;

                            Brush brush = GetBrush(fft_val, x, Effects.canvas_width);

                            g.DrawLine(new Pen(brush), x, Effects.canvas_height_center, x, Effects.canvas_height_center - fft_val / scaled_max_amplitude * 500.0f);
                        }
                        break;

                    case EqualizerType.Waveform_Bottom:
                        for (int x = 0; x < Effects.canvas_width; x++)
                        {
                            float fft_val = _local_fft.Length > x * wave_step_amount ? _local_fft[x * wave_step_amount].X : 0.0f;

                            Brush brush = GetBrush(fft_val, x, Effects.canvas_width);

                            g.DrawLine(new Pen(brush), x, Effects.canvas_height, x, Effects.canvas_height - Math.Abs(fft_val / scaled_max_amplitude) * 1000.0f);
                        }
                        break;

                    case EqualizerType.PowerBars:

                        //Perform FFT again to get frequencies
                        FastFourierTransform.FFT(false, (int)Math.Log(fftLength, 2.0), _local_fft);

                        while (flux_array.Count < freqs.Length)
                        {
                            flux_array.Add(0.0f);
                        }

                        int startF = 0;
                        int endF   = 0;

                        float threshhold = 300.0f;

                        for (int x = 0; x < freqs.Length - 1; x++)
                        {
                            startF = freqToBin(freqs[x]);
                            endF   = freqToBin(freqs[x + 1]);

                            float flux = 0.0f;

                            for (int j = startF; j <= endF; j++)
                            {
                                float curr_fft = (float)Math.Sqrt(_local_fft[j].X * _local_fft[j].X + _local_fft[j].Y * _local_fft[j].Y);
                                float prev_fft = (float)Math.Sqrt(_local_fft_previous[j].X * _local_fft_previous[j].X + _local_fft_previous[j].Y * _local_fft_previous[j].Y);

                                float value     = curr_fft - prev_fft;
                                float flux_calc = (value + Math.Abs(value)) / 2;
                                if (flux < flux_calc)
                                {
                                    flux = flux_calc;
                                }

                                flux = flux > threshhold ? 0.0f : flux;
                            }

                            flux_array[x] = flux;
                        }

                        //System.Diagnostics.Debug.WriteLine($"flux max: {flux_array.Max()}");

                        float bar_width = Effects.canvas_width / (float)(freqs.Length - 1);

                        for (int f_x = 0; f_x < freq_results.Length - 1; f_x++)
                        {
                            float fft_val = flux_array[f_x] / scaled_max_amplitude;

                            fft_val = Math.Min(1.0f, fft_val);

                            if (previous_freq_results[f_x] - fft_val > 0.10)
                            {
                                fft_val = previous_freq_results[f_x] - 0.15f;
                            }

                            float x      = f_x * bar_width;
                            float y      = Effects.canvas_height;
                            float width  = bar_width;
                            float height = fft_val * Effects.canvas_height;

                            previous_freq_results[f_x] = fft_val;

                            Brush brush = GetBrush(-(f_x % 2), f_x, freq_results.Length - 1);

                            g.FillRectangle(brush, x, y - height, width, height);
                        }

                        break;
                    }
                }

                var hander = NewLayerRender;
                if (hander != null)
                {
                    hander.Invoke(equalizer_layer.GetBitmap());
                }
                return(equalizer_layer);
            }
            catch (Exception exc)
            {
                Global.logger.Error("Error encountered in the Equalizer layer. Exception: " + exc.ToString());
                return(new EffectLayer());
            }
        }