Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

made color adjust sliders apply to the average color #2055

Merged
merged 3 commits into from
May 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,18 @@ public override EffectLayer Render(IGameState gamestate)
break;

case AmbilightType.AverageColor:
ambilight_layer.Set(Properties.Sequence, BitmapUtils.GetAverageColor(screen));
var average = BitmapUtils.GetAverageColor(screen);

if (Properties.BrightenImage)
average = ColorUtils.ChangeBrightness(average, Properties.BrightnessChange);

if (Properties.SaturateImage)
average = ColorUtils.ChangeSaturation(average, Properties.SaturationChange);

if (Properties.HueShiftImage)
average = ColorUtils.ChangeHue(average, Properties.HueShiftAngle);

ambilight_layer.Set(Properties.Sequence, average);
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@
<RowDefinition/>
</Grid.RowDefinitions>
<CheckBox IsChecked="{Binding Properties._BrightenImage}" x:Name="EnableBrightnessMod" Content="Brightness:" Grid.Row="0" Grid.Column="0"/>
<Slider Value="{Binding Properties._BrightnessChange}" x:Name="BrightnessSlider" IsEnabled="{Binding ElementName=EnableBrightnessMod, Path=IsChecked}" Minimum="-0.5" Maximum="0.5" TickFrequency="0.1" Grid.Row="0" Grid.Column="1"/>
<Slider Value="{Binding Properties._BrightnessChange}" x:Name="BrightnessSlider" IsEnabled="{Binding ElementName=EnableBrightnessMod, Path=IsChecked}" Minimum="0" Maximum="3" TickFrequency="0.1" Grid.Row="0" Grid.Column="1"/>
<Label Content="{Binding ElementName=BrightnessSlider, Path=Value}" ContentStringFormat="N1" Grid.Row="0" Grid.Column="2" />

<CheckBox IsChecked="{Binding Properties._SaturateImage}" x:Name="EnableSaturationMod" Content="Saturation:" Grid.Row="1" Grid.Column="0"/>
<Slider Value="{Binding Properties._SaturationChange}" x:Name="SaturationSlider" IsEnabled="{Binding ElementName=EnableSaturationMod, Path=IsChecked}" Minimum="0" Maximum="4" TickFrequency="0.1" Grid.Row="1" Grid.Column="1"/>
<Slider Value="{Binding Properties._SaturationChange}" x:Name="SaturationSlider" IsEnabled="{Binding ElementName=EnableSaturationMod, Path=IsChecked}" Minimum="0" Maximum="3" TickFrequency="0.1" Grid.Row="1" Grid.Column="1"/>
<Label Content="{Binding ElementName=SaturationSlider, Path=Value}" ContentStringFormat="N1" Grid.Row="1" Grid.Column="2"/>

<CheckBox IsChecked="{Binding Properties._HueShiftImage}" x:Name="EnableHueMod" Content="Hue:" Grid.Row="2" Grid.Column="0"/>
Expand Down
9 changes: 8 additions & 1 deletion Project-Aurora/Project-Aurora/Settings/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,14 @@ public void ProcessManager(object manager)
{
foreach (var plugin in this.Plugins)
{
plugin.Value.ProcessManager(manager);
try
{
plugin.Value.ProcessManager(manager);
}
catch(Exception e)
{
Global.logger.Error($"Failed to load plugin {plugin.Key}: {e.Message}");
}
}
}

Expand Down
12 changes: 6 additions & 6 deletions Project-Aurora/Project-Aurora/Utils/BitmapUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,21 @@ public static Color GetAverageColor(Image screenshot)
/// Returns a color matrix that when applied to an image alters its brightness.
/// Taken from https://docs.rainmeter.net/tips/colormatrix-guide/
/// </summary>
/// <param name="b">Brightness (-1..1)</param>
/// <param name="b">Brightness (0..4)</param>
/// <returns></returns>
public static float[][] GetBrightnessColorMatrix(float b) => new float[][] {
new float[] {1, 0, 0, 0, 0},//red
new float[] {0, 1, 0, 0, 0},//green
new float[] {0, 0, 1, 0, 0},//blue
new float[] {b, 0, 0, 0, 0},//red
new float[] {0, b, 0, 0, 0},//green
new float[] {0, 0, b, 0, 0},//blue
new float[] {0, 0, 0, 1, 0},//alpha
new float[] {b, b, b, 0, 1}
new float[] {0, 0, 0, 0, 1}
};

/// <summary>
/// Returns a color matrix that when applied to an image alters its saturation.
/// Taken from https://docs.rainmeter.net/tips/colormatrix-guide/
/// </summary>
/// <param name="s">Saturation (0..~5)</param>
/// <param name="s">Saturation (0..4)</param>
/// <returns></returns>
public static float[][] GetSaturationColorMatrix(float s)
{
Expand Down