diff --git a/Project-Aurora/ColorBox/ColorBox.csproj b/Project-Aurora/ColorBox/ColorBox.csproj
index 8f7ce9ebc..3ae093541 100644
--- a/Project-Aurora/ColorBox/ColorBox.csproj
+++ b/Project-Aurora/ColorBox/ColorBox.csproj
@@ -41,10 +41,14 @@
ColorBox.snk
+
+ ..\packages\Newtonsoft.Json.12.0.3\lib\net40\Newtonsoft.Json.dll
+
+
@@ -67,6 +71,9 @@
+
+
+
@@ -81,6 +88,7 @@
+
diff --git a/Project-Aurora/ColorBox/Implementation/ColorBox.cs b/Project-Aurora/ColorBox/Implementation/ColorBox.cs
index d5cc7337f..60f57850d 100644
--- a/Project-Aurora/ColorBox/Implementation/ColorBox.cs
+++ b/Project-Aurora/ColorBox/Implementation/ColorBox.cs
@@ -20,6 +20,7 @@ This program is provided to you under the terms of the Microsoft Public
using System.Windows.Input;
using System.ComponentModel;
using System.Windows.Data;
+using Aurora.EffectsEngine;
namespace ColorBox
{
@@ -97,7 +98,7 @@ private void ReverseGradientStop_Executed(object sender, ExecutedRoutedEventArgs
this.SetBrush();
}
- void InitTransform()
+ /*void InitTransform()
{
if (this.Brush.Transform == null || this.Brush.Transform.Value.IsIdentity)
{
@@ -112,120 +113,88 @@ void InitTransform()
this._BrushSetInternally = false;
}
- }
+ }*/
#region Private Properties
-
- double StartX
+ /*float StartX
{
- get { return (double)GetValue(StartXProperty); }
+ get { return (float)GetValue(StartXProperty); }
set { SetValue(StartXProperty, value); }
}
static readonly DependencyProperty StartXProperty =
- DependencyProperty.Register("StartX", typeof(double), typeof(ColorBox), new PropertyMetadata(0.5, new PropertyChangedCallback(StartXChanged)));
+ DependencyProperty.Register("StartX", typeof(float), typeof(ColorBox), new PropertyMetadata(0f, new PropertyChangedCallback(StartXChanged)));
static void StartXChanged(DependencyObject property, DependencyPropertyChangedEventArgs args)
{
ColorBox cp = property as ColorBox;
- if (cp.Brush is LinearGradientBrush)
- {
- cp._BrushSetInternally = true;
- (cp.Brush as LinearGradientBrush).StartPoint = new Point((double)args.NewValue, (cp.Brush as LinearGradientBrush).StartPoint.Y);
- cp._BrushSetInternally = false;
- }
+ cp._BrushSetInternally = true;
+ cp.Brush.start.X = (float)args.NewValue;
+ cp._BrushSetInternally = false;
}
- double StartY
+ float StartY
{
- get { return (double)GetValue(StartYProperty); }
+ get { return (float)GetValue(StartYProperty); }
set { SetValue(StartYProperty, value); }
}
static readonly DependencyProperty StartYProperty =
- DependencyProperty.Register("StartY", typeof(double), typeof(ColorBox), new PropertyMetadata(0.0, new PropertyChangedCallback(StartYChanged)));
+ DependencyProperty.Register("StartY", typeof(float), typeof(ColorBox), new PropertyMetadata(0.0f, new PropertyChangedCallback(StartYChanged)));
static void StartYChanged(DependencyObject property, DependencyPropertyChangedEventArgs args)
{
ColorBox cp = property as ColorBox;
- if (cp.Brush is LinearGradientBrush)
- {
- cp._BrushSetInternally = true;
- (cp.Brush as LinearGradientBrush).StartPoint = new Point((cp.Brush as LinearGradientBrush).StartPoint.X, (double)args.NewValue);
- cp._BrushSetInternally = false;
- }
+ cp._BrushSetInternally = true;
+ cp.Brush.start.Y = (float)args.NewValue;
+ cp._BrushSetInternally = false;
}
- double EndX
+ float EndX
{
- get { return (double)GetValue(EndXProperty); }
+ get { return (float)GetValue(EndXProperty); }
set { SetValue(EndXProperty, value); }
}
static readonly DependencyProperty EndXProperty =
- DependencyProperty.Register("EndX", typeof(double), typeof(ColorBox), new PropertyMetadata(0.5, new PropertyChangedCallback(EndXChanged)));
+ DependencyProperty.Register("EndX", typeof(float), typeof(ColorBox), new PropertyMetadata(1.0f, new PropertyChangedCallback(EndXChanged)));
static void EndXChanged(DependencyObject property, DependencyPropertyChangedEventArgs args)
{
ColorBox cp = property as ColorBox;
- if (cp.Brush is LinearGradientBrush)
- {
- cp._BrushSetInternally = true;
- (cp.Brush as LinearGradientBrush).EndPoint = new Point((double)args.NewValue, (cp.Brush as LinearGradientBrush).EndPoint.Y);
- cp._BrushSetInternally = false;
- }
+ cp._BrushSetInternally = true;
+ cp.Brush.end.X = (float)args.NewValue;
+ cp._BrushSetInternally = false;
}
- double EndY
+ float EndY
{
- get { return (double)GetValue(EndYProperty); }
+ get { return (float)GetValue(EndYProperty); }
set { SetValue(EndYProperty, value); }
}
static readonly DependencyProperty EndYProperty =
- DependencyProperty.Register("EndY", typeof(double), typeof(ColorBox), new PropertyMetadata(1.0, new PropertyChangedCallback(EndYChanged)));
+ DependencyProperty.Register("EndY", typeof(float), typeof(ColorBox), new PropertyMetadata(1.0f, new PropertyChangedCallback(EndYChanged)));
static void EndYChanged(DependencyObject property, DependencyPropertyChangedEventArgs args)
{
ColorBox cp = property as ColorBox;
- if (cp.Brush is LinearGradientBrush)
- {
- cp._BrushSetInternally = true;
- (cp.Brush as LinearGradientBrush).EndPoint = new Point((cp.Brush as LinearGradientBrush).EndPoint.X, (double)args.NewValue);
- cp._BrushSetInternally = false;
- }
- }
-
-
-
- double GradientOriginX
- {
- get { return (double)GetValue(GradientOriginXProperty); }
- set { SetValue(GradientOriginXProperty, value); }
- }
- static readonly DependencyProperty GradientOriginXProperty =
- DependencyProperty.Register("GradientOriginX", typeof(double), typeof(ColorBox), new PropertyMetadata(0.5, new PropertyChangedCallback(GradientOriginXChanged)));
- static void GradientOriginXChanged(DependencyObject property, DependencyPropertyChangedEventArgs args)
- {
- ColorBox cp = property as ColorBox;
- if (cp.Brush is RadialGradientBrush)
- {
- cp._BrushSetInternally = true;
- (cp.Brush as RadialGradientBrush).GradientOrigin = new Point((double)args.NewValue, (cp.Brush as RadialGradientBrush).GradientOrigin.Y);
- cp._BrushSetInternally = false;
- }
- }
-
- double GradientOriginY
+ cp._BrushSetInternally = true;
+ cp.Brush.end.Y = (float)args.NewValue;
+ cp._BrushSetInternally = false;
+ }*/
+ int Angle
{
- get { return (double)GetValue(GradientOriginYProperty); }
- set { SetValue(GradientOriginYProperty, value); }
+ get { return (int)GetValue(AngleProperty); }
+ set { SetValue(AngleProperty, value); }
}
- static readonly DependencyProperty GradientOriginYProperty =
- DependencyProperty.Register("GradientOriginY", typeof(double), typeof(ColorBox), new PropertyMetadata(0.5, new PropertyChangedCallback(GradientOriginYChanged)));
- static void GradientOriginYChanged(DependencyObject property, DependencyPropertyChangedEventArgs args)
+ static readonly DependencyProperty AngleProperty =
+ DependencyProperty.Register("Angle", typeof(int), typeof(ColorBox), new PropertyMetadata(0, new PropertyChangedCallback(AngleChanged)));
+ static void AngleChanged(DependencyObject property, DependencyPropertyChangedEventArgs args)
{
ColorBox cp = property as ColorBox;
- if (cp.Brush is RadialGradientBrush)
+
+ if (cp.Brush is LinearEffectBrush linearBrush)
{
cp._BrushSetInternally = true;
- (cp.Brush as RadialGradientBrush).GradientOrigin = new Point((cp.Brush as RadialGradientBrush).GradientOrigin.X, (double)args.NewValue);
+ linearBrush.Angle = (int)args.NewValue;
+ cp.SetBrush();
cp._BrushSetInternally = false;
}
+
}
-
double CenterX
{
get { return (double)GetValue(CenterXProperty); }
@@ -236,10 +205,12 @@ double CenterX
static void CenterXChanged(DependencyObject property, DependencyPropertyChangedEventArgs args)
{
ColorBox cp = property as ColorBox;
- if (cp.Brush is RadialGradientBrush)
+ if (cp.Brush is RadialEffectBrush radialBrush)
{
+ float centerX = (float)((double)args.NewValue % 1);
+
cp._BrushSetInternally = true;
- (cp.Brush as RadialGradientBrush).Center = new Point((double)args.NewValue, (cp.Brush as RadialGradientBrush).Center.Y);
+ radialBrush.Center.X = centerX;
cp._BrushSetInternally = false;
}
}
@@ -254,50 +225,36 @@ double CenterY
static void CenterYChanged(DependencyObject property, DependencyPropertyChangedEventArgs args)
{
ColorBox cp = property as ColorBox;
- if (cp.Brush is RadialGradientBrush)
+ if (cp.Brush is RadialEffectBrush radialBrush)
{
+ float centerY = (float)((double)args.NewValue);
+ if (centerY > 1f)
+ {
+ centerY %= 1;
+ }
cp._BrushSetInternally = true;
- (cp.Brush as RadialGradientBrush).Center = new Point((cp.Brush as RadialGradientBrush).Center.X, (double)args.NewValue);
+ radialBrush.Center.Y = centerY;
cp._BrushSetInternally = false;
}
}
- double RadiusX
+ float SampleWindowSize
{
- get { return (double)GetValue(RadiusXProperty); }
- set { SetValue(RadiusXProperty, value); }
+ get { return (float)GetValue(SampleWindowSizeProperty); }
+ set { SetValue(SampleWindowSizeProperty, value); }
}
- static readonly DependencyProperty RadiusXProperty =
- DependencyProperty.Register("RadiusX", typeof(double), typeof(ColorBox), new PropertyMetadata(0.5, new PropertyChangedCallback(RadiusXChanged)));
- static void RadiusXChanged(DependencyObject property, DependencyPropertyChangedEventArgs args)
+ static readonly DependencyProperty SampleWindowSizeProperty =
+ DependencyProperty.Register("SampleWindowSize", typeof(float), typeof(ColorBox), new PropertyMetadata(1.0f, new PropertyChangedCallback(SampleWindowSizeChanged)));
+ static void SampleWindowSizeChanged(DependencyObject property, DependencyPropertyChangedEventArgs args)
{
ColorBox cp = property as ColorBox;
- if (cp.Brush is RadialGradientBrush)
- {
- cp._BrushSetInternally = true;
- (cp.Brush as RadialGradientBrush).RadiusX = (double)args.NewValue;
- cp._BrushSetInternally = false;
- }
- }
- double RadiusY
- {
- get { return (double)GetValue(RadiusYProperty); }
- set { SetValue(RadiusYProperty, value); }
- }
- static readonly DependencyProperty RadiusYProperty =
- DependencyProperty.Register("RadiusY", typeof(double), typeof(ColorBox), new PropertyMetadata(0.5, new PropertyChangedCallback(RadiusYChanged)));
- static void RadiusYChanged(DependencyObject property, DependencyPropertyChangedEventArgs args)
- {
- ColorBox cp = property as ColorBox;
- if (cp.Brush is RadialGradientBrush)
- {
- cp._BrushSetInternally = true;
- (cp.Brush as RadialGradientBrush).RadiusY = (double)args.NewValue;
- cp._BrushSetInternally = false;
- }
+ cp._BrushSetInternally = true;
+ cp.Brush.SampleWindowSize = (float)args.NewValue;
+ cp._BrushSetInternally = false;
}
+
double BrushOpacity
{
get { return (double)GetValue(BrushOpacityProperty); }
@@ -313,41 +270,20 @@ double BrushOpacity
// cp._BrushSetInternally = false;
//}
- GradientSpreadMethod SpreadMethod
+ /*EffectBrush.BrushWrap SpreadMethod
{
- get { return (GradientSpreadMethod)GetValue(SpreadMethodProperty); }
+ get { return (EffectBrush.BrushWrap)GetValue(SpreadMethodProperty); }
set { SetValue(SpreadMethodProperty, value); }
}
static readonly DependencyProperty SpreadMethodProperty =
- DependencyProperty.Register("SpreadMethod", typeof(GradientSpreadMethod), typeof(ColorBox), new PropertyMetadata(GradientSpreadMethod.Pad, new PropertyChangedCallback(SpreadMethodChanged)));
+ DependencyProperty.Register("SpreadMethod", typeof(EffectBrush.BrushWrap), typeof(ColorBox), new PropertyMetadata(EffectBrush.BrushWrap.None, new PropertyChangedCallback(SpreadMethodChanged)));
static void SpreadMethodChanged(DependencyObject property, DependencyPropertyChangedEventArgs args)
{
ColorBox cp = property as ColorBox;
- if (cp.Brush is GradientBrush)
- {
- cp._BrushSetInternally = true;
- (cp.Brush as GradientBrush).SpreadMethod = (GradientSpreadMethod)args.NewValue;
- cp._BrushSetInternally = false;
- }
- }
-
- BrushMappingMode MappingMode
- {
- get { return (BrushMappingMode)GetValue(MappingModeProperty); }
- set { SetValue(MappingModeProperty, value); }
- }
- static readonly DependencyProperty MappingModeProperty =
- DependencyProperty.Register("MappingMode", typeof(BrushMappingMode), typeof(ColorBox), new PropertyMetadata(BrushMappingMode.RelativeToBoundingBox, new PropertyChangedCallback(MappingModeChanged)));
- static void MappingModeChanged(DependencyObject property, DependencyPropertyChangedEventArgs args)
- {
- ColorBox cp = property as ColorBox;
- if (cp.Brush is GradientBrush)
- {
- cp._BrushSetInternally = true;
- (cp.Brush as GradientBrush).MappingMode = (BrushMappingMode)args.NewValue;
- cp._BrushSetInternally = false;
- }
- }
+ cp._BrushSetInternally = true;
+ cp.Brush.wrap = (EffectBrush.BrushWrap)args.NewValue;
+ cp._BrushSetInternally = false;
+ }*/
#endregion
@@ -430,17 +366,18 @@ public IEnumerable AvailableBrushTypes
}
}
- public Brush Brush
+ public Brush MediaBrush
{
- get { return (Brush)GetValue(BrushProperty); }
- set { SetValue(BrushProperty, value); }
+ get { return (Brush)GetValue(MediaBrushProperty); }
+ set { SetValue(MediaBrushProperty, value); }
}
- public static readonly DependencyProperty BrushProperty =
- DependencyProperty.Register("Brush", typeof(Brush), typeof(ColorBox)
- , new FrameworkPropertyMetadata(null, new PropertyChangedCallback(BrushChangedInternal)));
- static void BrushChangedInternal(DependencyObject property, DependencyPropertyChangedEventArgs args)
+
+ public static readonly DependencyProperty MediaBrushProperty =
+ DependencyProperty.Register("MediaBrush", typeof(Brush), typeof(ColorBox)
+ , new FrameworkPropertyMetadata(null));//, new PropertyChangedCallback(MediaBrushChangedInternal)));
+ /*static void MediaBrushChangedInternal(DependencyObject property, DependencyPropertyChangedEventArgs args)
{
- ColorBox c = property as ColorBox;
+ ColorBox c = property as ColorBox;
Brush brush = args.NewValue as Brush;
if (!c._BrushSetInternally)
@@ -461,12 +398,7 @@ static void BrushChangedInternal(DependencyObject property, DependencyPropertyCh
{
LinearGradientBrush lgb = brush as LinearGradientBrush;
//c.Opacity = lgb.Opacity;
- c.StartX = lgb.StartPoint.X;
- c.StartY = lgb.StartPoint.Y;
- c.EndX = lgb.EndPoint.X;
- c.EndY = lgb.EndPoint.Y;
- c.MappingMode = lgb.MappingMode;
- c.SpreadMethod = lgb.SpreadMethod;
+
c.Gradients = new ObservableCollection(lgb.GradientStops);
c.BrushType = BrushTypes.Linear;
//c.Color = lgb.GradientStops.OrderBy(x => x.Offset).Last().Color;
@@ -474,25 +406,15 @@ static void BrushChangedInternal(DependencyObject property, DependencyPropertyCh
}
else
{
- /*
- c.BrushType = BrushTypes.Solid;
- c.Color = Color.FromArgb(255, 255, 0, 0);
- */
+
RadialGradientBrush rgb = brush as RadialGradientBrush;
- c.GradientOriginX = rgb.GradientOrigin.X;
- c.GradientOriginY = rgb.GradientOrigin.Y;
- c.RadiusX = rgb.RadiusX;
- c.RadiusY = rgb.RadiusY;
- c.CenterX = rgb.Center.X;
- c.CenterY = rgb.Center.Y;
- c.MappingMode = rgb.MappingMode;
- c.SpreadMethod = rgb.SpreadMethod;
+
c.Gradients = new ObservableCollection(rgb.GradientStops);
c.BrushType = BrushTypes.Radial;
//c.Color = rgb.GradientStops.OrderBy(x => x.Offset).Last().Color;
//c.SelectedGradient = rgb.GradientStops.OrderBy(x => x.Offset).Last();
-
+
}
c._BrushTypeSetInternally = false;
@@ -501,7 +423,64 @@ static void BrushChangedInternal(DependencyObject property, DependencyPropertyCh
{
c.RaiseBrushChangedEvent((Brush)args.NewValue);
}
- }
+ }*/
+ public EffectBrush Brush
+ {
+ get { return (EffectBrush)GetValue(BrushProperty); }
+ set { SetValue(BrushProperty, value); }
+ }
+ public static readonly DependencyProperty BrushProperty =
+ DependencyProperty.Register("Brush", typeof(EffectBrush), typeof(ColorBox)
+ , new FrameworkPropertyMetadata(null, new PropertyChangedCallback(BrushChangedInternal)));
+ static void BrushChangedInternal(DependencyObject property, DependencyPropertyChangedEventArgs args)
+ {
+ ColorBox c = property as ColorBox;
+ EffectBrush brush = args.NewValue as EffectBrush;
+
+ if (!c._BrushSetInternally)
+ {
+ c._BrushTypeSetInternally = true;
+
+ if (brush == null)
+ {
+ c.BrushType = BrushTypes.Solid;
+ c.Color = Color.FromArgb(255, 255, 0, 0);
+ }
+ else if (brush is SolidEffectBrush seb)
+ {
+ c.BrushType = BrushTypes.Solid;
+ c.Color = seb.GetGradientStopCollection()[0].Color;
+ }
+ else if (brush is LinearEffectBrush leb)
+ {
+
+ c.Gradients = new ObservableCollection(leb.GetGradientStopCollection());
+ c.BrushType = BrushTypes.Linear;
+ c.Angle = leb.Angle;
+ c.SampleWindowSize = leb.SampleWindowSize;
+ }
+ else
+ {
+
+ RadialEffectBrush reb = brush as RadialEffectBrush;
+
+ c.Gradients = new ObservableCollection(reb.GetGradientStopCollection());
+ c.SampleWindowSize = reb.SampleWindowSize;
+ c.BrushType = BrushTypes.Radial;
+ c.CenterX = reb.Center.X;
+ c.CenterY = reb.Center.Y;
+ //c.Color = rgb.GradientStops.OrderBy(x => x.Offset).Last().Color;
+ //c.SelectedGradient = rgb.GradientStops.OrderBy(x => x.Offset).Last();
+
+ }
+ c._BrushTypeSetInternally = false;
+ }
+ else
+ {
+ c.RaiseBrushChangedEvent(((EffectBrush)args.NewValue).MediaBrush);
+ }
+ c.MediaBrush = brush.MediaBrush;
+ }
public Color Color
{
@@ -763,6 +742,21 @@ void RaiseBrushChangedEvent(Brush brush)
#endregion
+ private ColorSpectrum CalcColorSpectrum()
+ {
+ var colors = new ColorSpectrum();
+ GradientStop first = new GradientStop(new Color(), 1.0f);
+ GradientStop last = new GradientStop(new Color(), 0.0f);
+ foreach (var grad in Gradients)
+ {
+ if (grad.Offset < first.Offset) first = grad;
+ if (grad.Offset > last.Offset) last = grad;
+ colors.SetColorAt((float)grad.Offset, ColorUtils.MediaColorToDrawingColor(grad.Color));
+ }
+ colors.SetColorAt(0, ColorUtils.MediaColorToDrawingColor(first.Color));
+ colors.SetColorAt(1, ColorUtils.MediaColorToDrawingColor(last.Color));
+ return colors;
+ }
internal void SetBrush()
{
if (!_UpdateBrush)
@@ -770,14 +764,6 @@ internal void SetBrush()
this._BrushSetInternally = true;
- // retain old opacity
- double opacity = 1;
- TransformGroup tempTG = null;
- if (this.Brush != null)
- {
- opacity = this.Brush.Opacity;
- tempTG = Brush.Transform as TransformGroup;
- }
switch (BrushType)
{
@@ -785,44 +771,28 @@ internal void SetBrush()
case BrushTypes.Solid:
- Brush = new SolidColorBrush(this.Color);
+ Brush = new SolidEffectBrush(new SolidColorBrush(this.Color));
break;
case BrushTypes.Linear:
+ var brush = new LinearEffectBrush(CalcColorSpectrum());
+ brush.SampleWindowSize = this.SampleWindowSize;
+ brush.Angle = Angle;
+ Brush = new LinearEffectBrush(brush);
- var brush = new LinearGradientBrush();
- foreach (GradientStop g in Gradients)
- {
- brush.GradientStops.Add(new GradientStop(g.Color, g.Offset));
- }
- brush.StartPoint = new Point(this.StartX, this.StartY);
- brush.EndPoint = new Point(this.EndX, this.EndY);
- brush.MappingMode = this.MappingMode;
- brush.SpreadMethod = this.SpreadMethod;
- Brush = brush;
-
break;
case BrushTypes.Radial:
- var brush1 = new RadialGradientBrush();
- foreach (GradientStop g in Gradients)
- {
- brush1.GradientStops.Add(new GradientStop(g.Color, g.Offset));
- }
- brush1.GradientOrigin = new Point(this.GradientOriginX, this.GradientOriginY);
- brush1.Center = new Point(this.CenterX, this.CenterY);
- brush1.RadiusX = this.RadiusX;
- brush1.RadiusY = this.RadiusY;
- brush1.MappingMode = this.MappingMode;
- brush1.SpreadMethod = this.SpreadMethod;
- Brush = brush1;
+ var brush1 = new RadialEffectBrush(CalcColorSpectrum());
+ brush1.SampleWindowSize = this.SampleWindowSize;
+ brush1.Center = new System.Drawing.PointF((float)CenterX, (float)CenterY);
+ Brush = (RadialEffectBrush)brush1.Clone();
break;
}
-
/*
if (this.BrushType != BrushTypes.None)
{
diff --git a/Project-Aurora/ColorBox/Implementation/GradientStopSlider.cs b/Project-Aurora/ColorBox/Implementation/GradientStopSlider.cs
index 8efd85c78..468bb7afa 100644
--- a/Project-Aurora/ColorBox/Implementation/GradientStopSlider.cs
+++ b/Project-Aurora/ColorBox/Implementation/GradientStopSlider.cs
@@ -26,18 +26,17 @@ protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
if (this.ColorBox != null)
{
this.ColorBox._BrushSetInternally = true;
- this.ColorBox._UpdateBrush = false;
+ this.ColorBox._UpdateBrush = false;
this.ColorBox.SelectedGradient = this.SelectedGradient;
this.ColorBox.Color = this.SelectedGradient.Color;
-
+
this.ColorBox._UpdateBrush = true;
//this.ColorBox._BrushSetInternally = false;
//e.Handled = true;
}
}
-
protected override void OnValueChanged(double oldValue, double newValue)
{
base.OnValueChanged(oldValue, newValue);
diff --git a/Project-Aurora/ColorBox/Themes/Generic.xaml b/Project-Aurora/ColorBox/Themes/Generic.xaml
index e47866212..d8016bc27 100644
--- a/Project-Aurora/ColorBox/Themes/Generic.xaml
+++ b/Project-Aurora/ColorBox/Themes/Generic.xaml
@@ -28,7 +28,7 @@
+
+
+
@@ -452,7 +530,7 @@
FocusVisualStyle="{x:Null}"
ColorBox="{Binding RelativeSource={RelativeSource TemplatedParent}}">
-
@@ -666,7 +744,7 @@
-
-
-
-
+
+
+
+
+ -->
-
-
+
+
-
-
+
-
-
-
+
-
+
-
+
+
+
+
+
+
+
+
- -->
+
diff --git a/Project-Aurora/Project-Aurora/EffectsEngine/ColorSpectrum.cs b/Project-Aurora/ColorBox/Utils/ColorSpectrum.cs
similarity index 96%
rename from Project-Aurora/Project-Aurora/EffectsEngine/ColorSpectrum.cs
rename to Project-Aurora/ColorBox/Utils/ColorSpectrum.cs
index c922004ea..2df817c89 100644
--- a/Project-Aurora/Project-Aurora/EffectsEngine/ColorSpectrum.cs
+++ b/Project-Aurora/ColorBox/Utils/ColorSpectrum.cs
@@ -3,8 +3,9 @@
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
+using ColorBox;
-namespace Aurora.EffectsEngine
+namespace ColorBox
{
///
/// A class that represents a spectrum of colors. After creating an instance, you can then retrieve a blended color within a range of [0.0f, 1.0f].
@@ -201,8 +202,8 @@ public Color GetColorAt(float position, float max_position = 1.0f, double opacit
}
}
- return Utils.ColorUtils.MultiplyColorByScalar(
- Utils.ColorUtils.BlendColors(
+ return ColorUtils.MultiplyColorByScalar(
+ ColorUtils.BlendColors(
colors[closest_lower], colors[closest_higher], ((double)(position - closest_lower) / (double)(closest_higher - closest_lower))
),
opacity
@@ -221,7 +222,7 @@ public Color GetColorAt(float position, float max_position = 1.0f, double opacit
public LinearGradientBrush ToLinearGradient(float width, float height = 0.0f, float x = 0.0f, float y = 0.0f, double opacity = 1.0D)
{
var newColors = colors.Keys
- .Select(val => new KeyValuePair(val, Utils.ColorUtils.MultiplyColorByScalar(colors[val], opacity)))
+ .Select(val => new KeyValuePair(val, ColorUtils.MultiplyColorByScalar(colors[val], opacity)))
.OrderBy(val => val.Key)
.ToList();
@@ -242,7 +243,7 @@ public LinearGradientBrush ToLinearGradient(float width, float height = 0.0f, fl
.OrderBy(val => val.Key)
.ToList();
- var endColor = Utils.ColorUtils.BlendColors(
+ var endColor = ColorUtils.BlendColors(
newColors.First().Value, newColors.Last().Value,
((double) (newColors.First().Key) / (double) (newColors.First().Key + 1.0f - newColors.Last().Key)));
@@ -288,7 +289,7 @@ public ColorSpectrum MultiplyByScalar(double scalar)
Dictionary newcolors = new Dictionary();
foreach (KeyValuePair kvp in colors)
- newcolors[kvp.Key] = Utils.ColorUtils.MultiplyColorByScalar(kvp.Value, scalar);
+ newcolors[kvp.Key] = ColorUtils.MultiplyColorByScalar(kvp.Value, scalar);
colors = newcolors;
diff --git a/Project-Aurora/ColorBox/Utils/ColorUtils.cs b/Project-Aurora/ColorBox/Utils/ColorUtils.cs
new file mode 100644
index 000000000..755308451
--- /dev/null
+++ b/Project-Aurora/ColorBox/Utils/ColorUtils.cs
@@ -0,0 +1,465 @@
+using Newtonsoft.Json;
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Globalization;
+using System.Windows.Data;
+
+namespace ColorBox
+{
+ public static class ColorExt
+ {
+ public static System.Drawing.Color ToDrawingColor(this System.Windows.Media.Color self)
+ {
+ return ColorUtils.MediaColorToDrawingColor(self);
+ }
+
+ public static System.Windows.Media.Color ToMediaColor(this System.Drawing.Color self)
+ {
+ return ColorUtils.DrawingColorToMediaColor(self);
+ }
+
+ public static System.Windows.Media.Color Clone(this System.Windows.Media.Color self)
+ {
+ return ColorUtils.CloneMediaColor(self);
+ }
+
+ public static System.Drawing.Color Clone(this System.Drawing.Color clr)
+ {
+ return ColorUtils.CloneDrawingColor(clr);
+ }
+ }
+
+ ///
+ /// Various color utilities
+ ///
+ public static class ColorUtils
+ {
+ private static Random randomizer = new Random();
+
+ ///
+ /// Converts from System.Windows.Media.Color to System.Drawing.Color
+ ///
+ /// A Windows Media Color
+ /// A Drawing Color
+ public static System.Drawing.Color MediaColorToDrawingColor(System.Windows.Media.Color in_color)
+ {
+ return System.Drawing.Color.FromArgb(in_color.A, in_color.R, in_color.G, in_color.B);
+ }
+
+ ///
+ /// Converts from System.Drawing.Color to System.Windows.Media.Color
+ ///
+ /// A Drawing Color
+ /// A Windows Media Color
+ public static System.Windows.Media.Color DrawingColorToMediaColor(System.Drawing.Color in_color)
+ {
+ return System.Windows.Media.Color.FromArgb(in_color.A, in_color.R, in_color.G, in_color.B);
+ }
+
+ ///
+ /// Multiplies a byte by a specified double balue
+ ///
+ /// Part of the color, as a byte
+ /// The value to multiply the byte by
+ /// The color byte
+ public static byte ColorByteMultiplication(byte color, double value)
+ {
+ byte returnbyte = color;
+
+ if ((double)returnbyte * value >= 255.0)
+ returnbyte = 255;
+ else if ((double)returnbyte * value <= 0.0)
+ returnbyte = 0;
+ else
+ returnbyte = (byte)((double)returnbyte * value);
+
+ return returnbyte;
+ }
+
+ ///
+ /// Blends two colors together by a specified amount
+ ///
+ /// The background color (When percent is at 0.0D, only this color is shown)
+ /// The foreground color (When percent is at 1.0D, only this color is shown)
+ /// The blending percent value
+ /// The blended color
+ public static System.Drawing.Color BlendColors(System.Drawing.Color background, System.Drawing.Color foreground, double percent)
+ {
+ if (percent < 0.0)
+ percent = 0.0;
+ else if (percent > 1.0)
+ percent = 1.0;
+
+ int Red = (byte)Math.Min((Int32)foreground.R * percent + (Int32)background.R * (1.0 - percent), 255);
+ int Green = (byte)Math.Min((Int32)foreground.G * percent + (Int32)background.G * (1.0 - percent), 255);
+ int Blue = (byte)Math.Min((Int32)foreground.B * percent + (Int32)background.B * (1.0 - percent), 255);
+ int Alpha = (byte)Math.Min((Int32)foreground.A * percent + (Int32)background.A * (1.0 - percent), 255);
+
+ return System.Drawing.Color.FromArgb(Alpha, Red, Green, Blue);
+ }
+
+ ///
+ /// Blends two colors together by a specified amount
+ ///
+ /// The background color (When percent is at 0.0D, only this color is shown)
+ /// The foreground color (When percent is at 1.0D, only this color is shown)
+ /// The blending percent value
+ /// The blended color
+ public static System.Windows.Media.Color BlendColors(System.Windows.Media.Color background, System.Windows.Media.Color foreground, double percent)
+ {
+ if (percent < 0.0)
+ percent = 0.0;
+ else if (percent > 1.0)
+ percent = 1.0;
+
+ int Red = (byte)Math.Min((Int32)foreground.R * percent + (Int32)background.R * (1.0 - percent), 255);
+ int Green = (byte)Math.Min((Int32)foreground.G * percent + (Int32)background.G * (1.0 - percent), 255);
+ int Blue = (byte)Math.Min((Int32)foreground.B * percent + (Int32)background.B * (1.0 - percent), 255);
+ int Alpha = (byte)Math.Min((Int32)foreground.A * percent + (Int32)background.A * (1.0 - percent), 255);
+
+ return System.Windows.Media.Color.FromArgb((byte)Alpha, (byte)Red, (byte)Green, (byte)Blue);
+ }
+
+ ///
+ /// Adds two colors together by using the alpha component of the foreground color
+ ///
+ /// The background color
+ /// The foreground color (must have transparency to allow color blending)
+ /// The sum of two colors
+ public static System.Drawing.Color AddColors(System.Drawing.Color background, System.Drawing.Color foreground)
+ {
+ if ((object)background == null)
+ return foreground;
+
+ if ((object)foreground == null)
+ return background;
+
+ return BlendColors(background, foreground, foreground.A / 255.0);
+ }
+
+ ///
+ /// Multiplies all non-alpha values by alpha/255.
+ /// Device integrations don't support alpha values, so we correct them here
+ ///
+ /// Color to correct
+ /// Corrected Color
+ public static System.Drawing.Color CorrectWithAlpha(System.Drawing.Color color)
+ {
+ float scalar = color.A / 255.0f;
+
+ int Red = ColorByteMultiplication(color.R, scalar);
+ int Green = ColorByteMultiplication(color.G, scalar);
+ int Blue = ColorByteMultiplication(color.B, scalar);
+
+ return System.Drawing.Color.FromArgb(255, Red, Green, Blue);
+ }
+
+ ///
+ /// Multiplies a Drawing Color instance by a scalar value
+ ///
+ /// The color to be multiplied
+ /// The scalar amount for multiplication
+ /// The multiplied Color
+ public static System.Drawing.Color MultiplyColorByScalar(System.Drawing.Color color, double scalar)
+ {
+ int Red = ColorByteMultiplication(color.R, scalar);
+ int Green = ColorByteMultiplication(color.G, scalar);
+ int Blue = ColorByteMultiplication(color.B, scalar);
+ int Alpha = ColorByteMultiplication(color.A, scalar);
+
+ return System.Drawing.Color.FromArgb(Alpha, Red, Green, Blue);
+ }
+
+ ///
+ /// Multiplies a Drawing Color instance by a scalar value
+ ///
+ /// The color to be multiplied
+ /// The scalar amount for multiplication
+ /// The multiplied Color
+ public static System.Windows.Media.Color MultiplyColorByScalar(System.Windows.Media.Color color, double scalar)
+ {
+ int Red = ColorByteMultiplication(color.R, scalar);
+ int Green = ColorByteMultiplication(color.G, scalar);
+ int Blue = ColorByteMultiplication(color.B, scalar);
+ int Alpha = ColorByteMultiplication(color.A, scalar);
+
+ return System.Windows.Media.Color.FromArgb((byte)Alpha, (byte)Red, (byte)Green, (byte)Blue);
+ }
+
+ ///
+ /// Generates a random color
+ ///
+ /// A random color
+ public static System.Drawing.Color GenerateRandomColor()
+ {
+ return System.Drawing.Color.FromArgb(randomizer.Next(255), randomizer.Next(255), randomizer.Next(255));
+ }
+
+ ///
+ /// Generates a random color within a certain base color range
+ ///
+ /// A base color range
+ /// A random color within a base range
+ public static System.Drawing.Color GenerateRandomColor(System.Drawing.Color baseColor)
+ {
+ int red = (randomizer.Next(255) + baseColor.R) / 2;
+ int green = (randomizer.Next(255) + baseColor.G) / 2;
+ int blue = (randomizer.Next(255) + baseColor.B) / 2;
+ int alpha = (255 + baseColor.A) / 2;
+
+ return System.Drawing.Color.FromArgb(alpha, red, green, blue);
+ }
+
+ ///
+ /// Returns an average color from a presented Bitmap
+ ///
+ /// The bitmap to be evaluated
+ /// An average color from the bitmap
+ public static Color GetAverageColor(System.Windows.Media.Imaging.BitmapSource bitmap)
+ {
+ var format = bitmap.Format;
+
+ if (format != System.Windows.Media.PixelFormats.Bgr24 &&
+ format != System.Windows.Media.PixelFormats.Bgr32 &&
+ format != System.Windows.Media.PixelFormats.Bgra32 &&
+ format != System.Windows.Media.PixelFormats.Pbgra32)
+ {
+ throw new InvalidOperationException("BitmapSource must have Bgr24, Bgr32, Bgra32 or Pbgra32 format");
+ }
+
+ var width = bitmap.PixelWidth;
+ var height = bitmap.PixelHeight;
+ var numPixels = width * height;
+ var bytesPerPixel = format.BitsPerPixel / 8;
+ var pixelBuffer = new byte[numPixels * bytesPerPixel];
+
+ bitmap.CopyPixels(pixelBuffer, width * bytesPerPixel, 0);
+
+ long blue = 0;
+ long green = 0;
+ long red = 0;
+
+ for (int i = 0; i < pixelBuffer.Length; i += bytesPerPixel)
+ {
+ blue += pixelBuffer[i];
+ green += pixelBuffer[i + 1];
+ red += pixelBuffer[i + 2];
+ }
+
+ return Color.FromArgb((byte)(red / numPixels), (byte)(green / numPixels), (byte)(blue / numPixels));
+ }
+
+ public static Color GetColorFromInt(int interger)
+ {
+ if (interger < 0)
+ interger = 0;
+ else if (interger > 16777215)
+ interger = 16777215;
+
+ int R = interger >> 16;
+ int G = (interger >> 8) & 255;
+ int B = interger & 255;
+
+ return Color.FromArgb(R, G, B);
+ }
+
+ public static int GetIntFromColor(Color color)
+ {
+ return (color.R << 16) | (color.G << 8) | (color.B);
+ }
+
+ public static void ToHsv(Color color, out double hue, out double saturation, out double value)
+ {
+ var max = Math.Max(color.R, Math.Max(color.G, color.B));
+ var min = Math.Min(color.R, Math.Min(color.G, color.B));
+
+ var delta = max - min;
+
+ hue = 0d;
+ if (delta != 0)
+ {
+ if (color.R == max) hue = (color.G - color.B) / (double)delta;
+ else if (color.G == max) hue = 2d + (color.B - color.R) / (double)delta;
+ else if (color.B == max) hue = 4d + (color.R - color.G) / (double)delta;
+ }
+
+ hue *= 60;
+ if (hue < 0.0) hue += 360;
+
+ saturation = (max == 0) ? 0 : 1d - (1d * min / max);
+ value = max / 255d;
+ }
+
+ public static Color FromHsv(double hue, double saturation, double value)
+ {
+ saturation = Math.Max(Math.Min(saturation, 1), 0);
+ value = Math.Max(Math.Min(value, 1), 0);
+
+ var hi = Convert.ToInt32(Math.Floor(hue / 60)) % 6;
+ var f = hue / 60 - Math.Floor(hue / 60);
+
+ value *= 255;
+ var v = (byte)(value);
+ var p = (byte)(value * (1 - saturation));
+ var q = (byte)(value * (1 - f * saturation));
+ var t = (byte)(value * (1 - (1 - f) * saturation));
+
+ switch (hi)
+ {
+ case 0: return Color.FromArgb(v, t, p);
+ case 1: return Color.FromArgb(q, v, p);
+ case 2: return Color.FromArgb(p, v, t);
+ case 3: return Color.FromArgb(p, q, v);
+ case 4: return Color.FromArgb(t, p, v);
+ default: return Color.FromArgb(v, p, q);
+ }
+ }
+
+ ///
+ /// Changes the hue of
+ ///
+ /// Color to be modified
+ /// Hue offset in degrees
+ /// Color with modified hue
+ public static Color ChangeHue(Color color, double offset)
+ {
+ if (offset == 0)
+ return color;
+
+ ToHsv(color, out var hue, out var saturation, out var value);
+
+ hue += offset;
+
+ while (hue > 360) hue -= 360;
+ while (hue < 0) hue += 360;
+
+ return FromHsv(hue, saturation, value);
+ }
+
+
+
+ ///
+ /// Returns a Luma coefficient for brightness of a color
+ ///
+ /// Color to be evaluated
+ /// The brightness of the color. [0 = Dark, 255 = Bright]
+ public static byte GetColorBrightness(System.Drawing.Color color)
+ {
+ //Source: http://stackoverflow.com/a/12043228
+ return (byte)(0.2126 * color.R + 0.7152 * color.G + 0.0722 * color.B);
+ }
+
+ ///
+ /// Returns whether or not a color is considered to be dark, based on Luma coefficient
+ ///
+ /// Color to be evaluated
+ /// Whether or not the color is dark
+ public static bool IsColorDark(System.Drawing.Color color)
+ {
+ //Source: http://stackoverflow.com/a/12043228
+ return GetColorBrightness(color) < 40;
+ }
+
+ public static System.Windows.Media.Color CloneMediaColor(System.Windows.Media.Color clr)
+ {
+ return System.Windows.Media.Color.FromArgb(clr.A, clr.R, clr.G, clr.B);
+ }
+
+ public static System.Drawing.Color CloneDrawingColor(System.Drawing.Color clr)
+ {
+ return System.Drawing.Color.FromArgb(clr.ToArgb());
+ }
+ }
+
+ public class ColorConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return ColorUtils.DrawingColorToMediaColor((System.Drawing.Color)value);
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return ColorUtils.MediaColorToDrawingColor((System.Windows.Media.Color)value);
+ }
+ }
+
+ ///
+ /// Converts between a RealColor and Media color so that the RealColor class can be used with the Xceed Color Picker
+ ///
+ public class RealColorConverter : IValueConverter {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => ((RealColor)value).GetMediaColor();
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => new RealColor((System.Windows.Media.Color)value);
+ }
+
+ public class BoolToColorConverter : IValueConverter
+ {
+ public static Tuple TextWhiteRed = new Tuple(Color.FromArgb(255, 186, 186, 186), Color.Red);
+
+ public static Tuple TextRedWhite = new Tuple(Color.Red, Color.FromArgb(255, 186, 186, 186));
+
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ bool b = (bool)value;
+ Tuple clrs = parameter as Tuple ?? TextWhiteRed;
+ Color clr = b ? clrs.Item1 : clrs.Item2;
+
+ return new System.Windows.Media.SolidColorBrush(ColorUtils.DrawingColorToMediaColor(clr));
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ public class RealColor : ICloneable
+ {
+ [JsonProperty]
+ private System.Drawing.Color Color { get; set; }
+
+ public RealColor()
+ {
+ Color = Color.Transparent;
+ }
+
+ public RealColor(System.Windows.Media.Color clr)
+ {
+ this.SetMediaColor(clr);
+ }
+
+ public RealColor(System.Drawing.Color color)
+ {
+ this.Color = color.Clone();
+ }
+
+ public System.Drawing.Color GetDrawingColor()
+ {
+ return Color.Clone();
+ }
+
+ public System.Windows.Media.Color GetMediaColor()
+ {
+ return Color.ToMediaColor();
+ }
+
+ public void SetDrawingColor(System.Drawing.Color clr)
+ {
+ this.Color = clr.Clone();
+ }
+
+ public void SetMediaColor(System.Windows.Media.Color clr)
+ {
+ this.Color = clr.ToDrawingColor();
+ }
+
+ public object Clone()
+ {
+ return new RealColor(this.Color.Clone());
+ }
+
+ public static implicit operator System.Drawing.Color(RealColor c) => c.GetDrawingColor();
+ public static implicit operator System.Windows.Media.Color(RealColor c) => c.GetMediaColor();
+ }
+}
diff --git a/Project-Aurora/ColorBox/Utils/EffectBrush.cs b/Project-Aurora/ColorBox/Utils/EffectBrush.cs
new file mode 100644
index 000000000..a2c25fe49
--- /dev/null
+++ b/Project-Aurora/ColorBox/Utils/EffectBrush.cs
@@ -0,0 +1,570 @@
+using ColorBox;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows;
+
+namespace Aurora.EffectsEngine
+{
+ public abstract class EffectBrush : ICloneable
+ {
+
+ [JsonProperty("color_gradients")]
+ public SortedDictionary ColorGradients = new SortedDictionary();
+ public float SampleWindowSize = 1;
+
+ protected System.Drawing.Brush _drawingBrush = null;
+ protected System.Windows.Media.Brush _mediaBrush = null;
+
+ public System.Windows.Media.GradientStopCollection GetGradientStopCollection()
+ {
+ System.Windows.Media.GradientStopCollection collection = new System.Windows.Media.GradientStopCollection();
+
+ foreach (var kvp in ColorGradients)
+ {
+ collection.Add(
+ new System.Windows.Media.GradientStop(
+ ColorUtils.DrawingColorToMediaColor(kvp.Value),
+ kvp.Key)
+ );
+ }
+ return collection;
+ }
+ public System.Windows.Media.Brush MediaBrush => GetMediaBrush();
+ protected void CheckColorGradients()
+ {
+ if (ColorGradients.Count > 0)
+ {
+ bool firstFound = false;
+ System.Drawing.Color first_color = new System.Drawing.Color();
+ System.Drawing.Color last_color = new System.Drawing.Color();
+
+ foreach (var kvp in ColorGradients)
+ {
+ if (!firstFound)
+ {
+ first_color = kvp.Value;
+ firstFound = true;
+ }
+
+ last_color = kvp.Value;
+ }
+
+ if (!ColorGradients.ContainsKey(0.0f))
+ ColorGradients.Add(0.0f, first_color);
+
+ if (!ColorGradients.ContainsKey(1.0f))
+ ColorGradients.Add(1.0f, last_color);
+ }
+ else
+ {
+ if (!ColorGradients.ContainsKey(0.0f))
+ ColorGradients.Add(0.0f, System.Drawing.Color.Transparent);
+
+ if (!ColorGradients.ContainsKey(1.0f))
+ ColorGradients.Add(1.0f, System.Drawing.Color.Transparent);
+ }
+ }
+ protected System.Drawing.Color GetColorAtShift(float shift)
+ {
+ float previousKey = 0;
+ foreach (var kvp in ColorGradients)
+ {
+ if (kvp.Key >= shift)
+ {
+ return ColorUtils.BlendColors(ColorGradients[previousKey], kvp.Value, (shift - previousKey) / (kvp.Key - previousKey));
+ }
+ previousKey = kvp.Key;
+ }
+ return new System.Drawing.Color();
+ }
+
+ public abstract System.Drawing.Brush GetDrawingBrush(float shift = 0, System.Drawing.Rectangle rect = new System.Drawing.Rectangle());
+
+ public abstract System.Windows.Media.Brush GetMediaBrush();
+
+ public virtual ColorSpectrum GetColorSpectrum()
+ {
+ ColorSpectrum spectrum = new ColorSpectrum();
+
+ foreach (var color in ColorGradients)
+ spectrum.SetColorAt(color.Key, color.Value);
+
+ return spectrum;
+ }
+
+ ///
+ /// Blends two EffectBrushes together by a specified amount
+ ///
+ /// The foreground EffectBrush (When percent is at 1.0D, only this EffectBrush is shown)
+ /// The blending percent value
+ /// The blended EffectBrush
+ public abstract EffectBrush BlendEffectBrush(EffectBrush otherBrush, double percent);
+
+ public object Clone()
+ {
+ var clone = (EffectBrush)this.MemberwiseClone();
+ HandleCloned(clone);
+ return clone;
+ }
+ protected virtual void HandleCloned(EffectBrush clone)
+ {
+ //Nothing particular in the base class, but maybe useful for children.
+ //Not abstract so children may not implement this if they don't need to.
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != this.GetType()) return false;
+ return Equals((EffectBrush)obj);
+ }
+
+ public bool Equals(EffectBrush p)
+ {
+ if (ReferenceEquals(null, p)) return false;
+ if (ReferenceEquals(this, p)) return true;
+
+ return (SampleWindowSize == p.SampleWindowSize &&
+ ColorGradients.Equals(p.ColorGradients));
+ }
+
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hash = 17;
+ hash = hash * 23 + SampleWindowSize.GetHashCode();
+ hash = hash * 23 + ColorGradients.GetHashCode();
+ return hash;
+ }
+ }
+ }
+ public class SolidEffectBrush : EffectBrush
+ {
+ public SolidEffectBrush()
+ {
+
+ ColorGradients.Add(0.0f, System.Drawing.Color.Red);
+ ColorGradients.Add(1.0f, System.Drawing.Color.Blue);
+ }
+
+ public SolidEffectBrush(EffectBrush otherBrush)
+ {
+ this.ColorGradients = otherBrush.ColorGradients;
+ this.SampleWindowSize = otherBrush.SampleWindowSize;
+ }
+ public SolidEffectBrush(ColorSpectrum spectrum)
+ {
+ foreach (var color in spectrum.GetSpectrumColors())
+ ColorGradients.Add(color.Key, color.Value);
+ }
+
+ public SolidEffectBrush(System.Windows.Media.SolidColorBrush brush)
+ {
+ ColorGradients.Add(0.0f, ColorUtils.MediaColorToDrawingColor(brush.Color));
+ ColorGradients.Add(1.0f, ColorUtils.MediaColorToDrawingColor(brush.Color));
+
+ CheckColorGradients();
+ }
+
+ public override System.Drawing.Brush GetDrawingBrush(float shift, System.Drawing.Rectangle rect)
+ {
+ if (true/*_drawingbrush == null*/)
+ {
+ _drawingBrush = new System.Drawing.SolidBrush(ColorGradients[0.0f]);
+ }
+ return _drawingBrush;
+ }
+ public override System.Windows.Media.Brush GetMediaBrush()
+ {
+ if (_mediaBrush == null)
+ {
+ System.Windows.Media.SolidColorBrush brush = new System.Windows.Media.SolidColorBrush(
+ ColorUtils.DrawingColorToMediaColor(ColorGradients[0.0f])
+ );
+ brush.Freeze();
+
+ _mediaBrush = brush;
+ }
+
+ return _mediaBrush;
+ }
+
+ public override ColorSpectrum GetColorSpectrum() => new ColorSpectrum(ColorGradients[0.0f]);
+
+
+ ///
+ /// Blends two EffectBrushes together by a specified amount
+ ///
+ /// The foreground EffectBrush (When percent is at 1.0D, only this EffectBrush is shown)
+ /// The blending percent value
+ /// The blended EffectBrush
+ public override EffectBrush BlendEffectBrush(EffectBrush otherBrush, double percent)
+ {
+ if (percent <= 0.0)
+ return (EffectBrush)this.Clone();
+ else if (percent >= 1.0)
+ return (EffectBrush)otherBrush.Clone();
+
+ ColorSpectrum currentSpectrum = new ColorSpectrum(GetColorSpectrum());
+ ColorSpectrum newSpectrum = new ColorSpectrum(currentSpectrum).MultiplyByScalar(1.0 - percent);
+
+ foreach (var kvp in otherBrush.ColorGradients)
+ {
+ System.Drawing.Color bgColor = currentSpectrum.GetColorAt(kvp.Key);
+ System.Drawing.Color fgColor = kvp.Value;
+
+ newSpectrum.SetColorAt(kvp.Key, ColorUtils.BlendColors(bgColor, fgColor, percent));
+ }
+
+ EffectBrush returnBrush = new SolidEffectBrush(newSpectrum);
+ returnBrush.SampleWindowSize = SampleWindowSize * (float)(1.0 - percent) + otherBrush.SampleWindowSize * (float)percent;
+
+ return returnBrush;
+ }
+
+ }
+ public class LinearEffectBrush : EffectBrush
+ {
+
+ public int Angle = 0;
+ public LinearEffectBrush()
+ {
+ ColorGradients.Add(0.0f, System.Drawing.Color.Red);
+ ColorGradients.Add(1.0f, System.Drawing.Color.Blue);
+ }
+
+ public LinearEffectBrush(EffectBrush otherBrush)
+ {
+ this.ColorGradients = otherBrush.ColorGradients;
+ this.SampleWindowSize = otherBrush.SampleWindowSize;
+ if (otherBrush is LinearEffectBrush otherLinearBrush)
+ this.Angle = otherLinearBrush.Angle;
+ }
+
+ public LinearEffectBrush(ColorSpectrum spectrum)
+ {
+ foreach (var color in spectrum.GetSpectrumColors())
+ ColorGradients.Add(color.Key, color.Value);
+
+ CheckColorGradients();
+ }
+
+ public LinearEffectBrush(System.Windows.Media.LinearGradientBrush brush)
+ {
+
+ foreach (var grad in brush.GradientStops)
+ {
+ if (!ColorGradients.ContainsKey((float)grad.Offset) && ((float)grad.Offset >= 0.0f && (float)grad.Offset <= 1.0f))
+ ColorGradients.Add(
+ (float)grad.Offset,
+ ColorUtils.MediaColorToDrawingColor(grad.Color)
+ );
+ }
+
+
+ CheckColorGradients();
+ }
+
+ public override System.Drawing.Brush GetDrawingBrush(float shift, System.Drawing.Rectangle rect)
+ {
+ if (true/*_drawingbrush == null*/)
+ {
+
+ if (SampleWindowSize == 0)
+ {
+ _drawingBrush = new System.Drawing.SolidBrush(GetColorAtShift(shift));
+ }
+ else
+ {
+ double angle = (Angle) / 360.0 * 2 * Math.PI;
+ float sin = (float)Math.Sin(angle); //* (1 / SampleWindowSize)/2;
+ float cos = (float)Math.Cos(angle);// * (1 / SampleWindowSize)/2;
+ double angle2 = (Angle)%90 / 360.0 * 2 * Math.PI;
+ float move = shift;// (float)(Math.Cos(angle2) > Math.Sin(angle2) ? shift / Math.Cos(angle2) : shift / Math.Sin(angle2));// + (float)(Math.Sin((Angle + 45) % 90 * 2 / 360.0 * 2 * Math.PI) * (Math.Sqrt(2) - 1)) * shift;
+ var start = new System.Drawing.PointF(move * (1 / SampleWindowSize), 0f);
+ var end = new System.Drawing.PointF((move + 1) * (1 / SampleWindowSize), 0f);
+ System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(
+ start,
+ end,
+ System.Drawing.Color.Red,
+ System.Drawing.Color.Red
+ );
+
+ List brush_colors = new List();
+ List brush_positions = new List();
+
+ foreach (var kvp in ColorGradients)
+ {
+ brush_positions.Add(kvp.Key);
+ brush_colors.Add(kvp.Value);
+ }
+
+ System.Drawing.Drawing2D.ColorBlend color_blend = new System.Drawing.Drawing2D.ColorBlend();
+ color_blend.Colors = brush_colors.ToArray();
+ color_blend.Positions = brush_positions.ToArray();
+ brush.InterpolationColors = color_blend;
+
+ brush.WrapMode = System.Drawing.Drawing2D.WrapMode.Tile;
+
+ if(!rect.IsEmpty)
+ {
+ brush.TranslateTransform(rect.X, rect.Y);
+ brush.ScaleTransform(rect.Width, rect.Height);
+ }
+ brush.RotateTransform((float)Angle);
+ _drawingBrush = brush;
+ }
+ }
+
+ return _drawingBrush;
+ }
+ public override System.Windows.Media.Brush GetMediaBrush()
+ {
+ if (_mediaBrush == null)
+ {
+ //double angle = (Angle + 225) / 360.0 * 2 * Math.PI;
+ double angle = Angle / 360.0 * 2 * Math.PI;
+ double sin = Math.Sin(angle);// * ((Math.Sqrt(2) - 1) * Math.Abs(Math.Sin(angle * 2 / 360.0 * 2 * Math.PI)) + 1); //* (1 / SampleWindowSize)/2;
+ double cos = Math.Cos(angle);// * ((Math.Sqrt(2) - 1) * Math.Abs(Math.Sin((Angle) * 2 / 360.0 * 2 * Math.PI)) + 1);// * (1 / SampleWindowSize)/2;
+ double size = (sin < cos? (1/sin+1)/2: (1/cos + 1) / 2);// 1/Math.Tan(angle);//Math.Sqrt(sin * sin + cos * cos);// Math.Abs(Math.Cos((Angle) * 2 / 360.0 * 2 * Math.PI))*2;
+ //double size = (sin > cos ? 2/(sin + sin* sin) : 2 / (cos + cos* cos));
+ System.Windows.Media.LinearGradientBrush brush = new System.Windows.Media.LinearGradientBrush(GetGradientStopCollection());
+ brush.StartPoint = new System.Windows.Point(0, 0);// phase + cos, phase + sin);
+ brush.EndPoint = new System.Windows.Point( cos , sin);
+
+ /*switch (wrap)
+ {
+ case BrushWrap.None:
+ brush.SpreadMethod = System.Windows.Media.GradientSpreadMethod.Pad;
+ break;
+ case BrushWrap.Repeat:
+ brush.SpreadMethod = System.Windows.Media.GradientSpreadMethod.Repeat;
+ break;
+ case BrushWrap.Reflect:
+ brush.SpreadMethod = System.Windows.Media.GradientSpreadMethod.Reflect;
+ break;
+ }*/
+ brush.SpreadMethod = System.Windows.Media.GradientSpreadMethod.Repeat;
+ _mediaBrush = brush;
+ }
+
+ return _mediaBrush;
+ }
+
+ ///
+ /// Blends two EffectBrushes together by a specified amount
+ ///
+ /// The foreground EffectBrush (When percent is at 1.0D, only this EffectBrush is shown)
+ /// The blending percent value
+ /// The blended EffectBrush
+ public override EffectBrush BlendEffectBrush(EffectBrush otherBrush, double percent)
+ {
+ if (percent <= 0.0)
+ return (EffectBrush)this.Clone();
+ else if (percent >= 1.0)
+ return (EffectBrush)otherBrush.Clone();
+
+ ColorSpectrum currentSpectrum = new ColorSpectrum(GetColorSpectrum());
+ ColorSpectrum newSpectrum = new ColorSpectrum(currentSpectrum).MultiplyByScalar(1.0 - percent);
+
+ foreach (var kvp in otherBrush.ColorGradients)
+ {
+ System.Drawing.Color bgColor = currentSpectrum.GetColorAt(kvp.Key);
+ System.Drawing.Color fgColor = kvp.Value;
+
+ newSpectrum.SetColorAt(kvp.Key, ColorUtils.BlendColors(bgColor, fgColor, percent));
+ }
+
+ EffectBrush returnBrush = new LinearEffectBrush(newSpectrum);
+ returnBrush.SampleWindowSize = SampleWindowSize * (float)(1.0 - percent) + otherBrush.SampleWindowSize * (float)percent;
+
+ return returnBrush;
+ }
+ }
+ public class RadialEffectBrush : EffectBrush
+ {
+ public System.Drawing.PointF Center = new System.Drawing.PointF(0.5f, 0.5f);
+ public RadialEffectBrush()
+ {
+
+ ColorGradients.Add(0.0f, System.Drawing.Color.Red);
+ ColorGradients.Add(1.0f, System.Drawing.Color.Blue);
+ }
+
+ public RadialEffectBrush(EffectBrush otherBrush)
+ {
+ this.ColorGradients = otherBrush.ColorGradients;
+ this.SampleWindowSize = otherBrush.SampleWindowSize;
+ if (otherBrush is RadialEffectBrush otherRadialBrush)
+ this.Center = otherRadialBrush.Center;
+
+ }
+
+ public RadialEffectBrush(ColorSpectrum spectrum)
+ {
+ foreach (var color in spectrum.GetSpectrumColors())
+ ColorGradients.Add(color.Key, color.Value);
+ }
+ public RadialEffectBrush(System.Windows.Media.RadialGradientBrush brush)
+ {
+
+ foreach (var grad in brush.GradientStops)
+ {
+ if (!ColorGradients.ContainsKey((float)grad.Offset) && ((float)grad.Offset >= 0.0f && (float)grad.Offset <= 1.0f))
+ ColorGradients.Add(
+ (float)grad.Offset,
+ ColorUtils.MediaColorToDrawingColor(grad.Color)
+ );
+ }
+
+ CheckColorGradients();
+ }
+ protected SortedDictionary GetColorGradientsForWindow(float shift, float window_size, float starting_value = 0)
+ {
+ SortedDictionary gradients = new SortedDictionary();
+ if (window_size == 0)
+ {
+ var color = GetColorAtShift(shift);
+ gradients[0] = color;
+ gradients[1] = color;
+ return gradients;
+ }
+
+ float previousKey = 0;
+ foreach (var kvp in ColorGradients)
+ {
+ if (kvp.Key >= shift)
+ {
+ if (gradients.Count == 0 && kvp.Key != 0)
+ {
+ gradients[starting_value / window_size] = ColorUtils.BlendColors(ColorGradients[previousKey], kvp.Value, (shift - previousKey) / (kvp.Key - previousKey));
+ }
+
+ float index = (starting_value + kvp.Key - shift) / window_size;
+ if (kvp.Key <= shift + window_size - starting_value && index <= 1)
+ {
+ gradients[index] = kvp.Value;
+ }
+ else
+ {
+ gradients[1] = ColorUtils.BlendColors(ColorGradients[previousKey], kvp.Value, (shift + window_size - starting_value - previousKey) / (kvp.Key - previousKey));
+ return gradients;
+ }
+
+ if (kvp.Key == 1)
+ {
+ /*if(window_size - (1 - shift) <= 0.05f)
+ {
+ gradients[1] = ColorUtils.BlendColors(kvp.Value, colorGradients[0], window_size - (1 - shift) / 0.05f);
+ return gradients;
+ }*/
+ foreach (var gradient in GetColorGradientsForWindow(0, window_size, (1 - shift)))
+ {
+ gradients[gradient.Key] = gradient.Value;
+ }
+ }
+ }
+ previousKey = kvp.Key;
+ }
+ return gradients;
+ }
+ public override System.Drawing.Brush GetDrawingBrush(float shift, System.Drawing.Rectangle rect)
+ {
+ if (true/*_drawingbrush == null*/)
+ {
+ System.Drawing.Drawing2D.GraphicsPath g_path = new System.Drawing.Drawing2D.GraphicsPath();
+ g_path.AddEllipse(new System.Drawing.RectangleF(-(float)(Math.Sqrt(2)/2 - 0.5), -(float)(Math.Sqrt(2)/2 - 0.5), (float)Math.Sqrt(2), (float)Math.Sqrt(2)));
+
+ System.Drawing.Drawing2D.PathGradientBrush brush = new System.Drawing.Drawing2D.PathGradientBrush(
+ g_path
+ );
+
+ List brush_colors = new List();
+ List brush_positions = new List();
+
+ foreach (var kvp in GetColorGradientsForWindow(Math.Abs(shift), SampleWindowSize))
+ {
+ if (shift < 0)
+ brush_positions.Add(1.0f - kvp.Key);
+ else
+ brush_positions.Add(kvp.Key);
+ brush_colors.Add(kvp.Value);
+ }
+
+ if (shift < 0)
+ {
+ brush_colors.Reverse();
+ brush_positions.Reverse();
+ }
+
+ brush.CenterPoint = Center;
+
+ System.Drawing.Drawing2D.ColorBlend color_blend = new System.Drawing.Drawing2D.ColorBlend();
+ color_blend.Colors = brush_colors.ToArray();
+ color_blend.Positions = brush_positions.ToArray();
+ brush.InterpolationColors = color_blend;
+
+ //brush.TranslateTransform(0, -(brush_width - brush_height) / 2);
+ if (!rect.IsEmpty)
+ {
+ brush.TranslateTransform(rect.X, rect.Y);
+ brush.ScaleTransform(rect.Width, rect.Height);
+ }
+ _drawingBrush = brush;
+ }
+
+ return _drawingBrush;
+ }
+ public override System.Windows.Media.Brush GetMediaBrush()
+ {
+ if (_mediaBrush == null)
+ {
+
+ System.Windows.Media.RadialGradientBrush brush = new System.Windows.Media.RadialGradientBrush(GetGradientStopCollection());
+ brush.Center = new System.Windows.Point(Center.X, Center.Y);
+ brush.RadiusX = 0.5;
+ brush.RadiusY = 0.5;
+ //brush.
+
+ brush.SpreadMethod = System.Windows.Media.GradientSpreadMethod.Pad;
+ _mediaBrush = brush;
+ }
+
+ return _mediaBrush;
+ }
+
+ ///
+ /// Blends two EffectBrushes together by a specified amount
+ ///
+ /// The foreground EffectBrush (When percent is at 1.0D, only this EffectBrush is shown)
+ /// The blending percent value
+ /// The blended EffectBrush
+ public override EffectBrush BlendEffectBrush(EffectBrush otherBrush, double percent)
+ {
+ if (percent <= 0.0)
+ return (EffectBrush)this.Clone();
+ else if (percent >= 1.0)
+ return (EffectBrush)otherBrush.Clone();
+
+ ColorSpectrum currentSpectrum = new ColorSpectrum(GetColorSpectrum());
+ ColorSpectrum newSpectrum = new ColorSpectrum(currentSpectrum).MultiplyByScalar(1.0 - percent);
+
+ foreach (var kvp in otherBrush.ColorGradients)
+ {
+ System.Drawing.Color bgColor = currentSpectrum.GetColorAt(kvp.Key);
+ System.Drawing.Color fgColor = kvp.Value;
+
+ newSpectrum.SetColorAt(kvp.Key, ColorUtils.BlendColors(bgColor, fgColor, percent));
+ }
+
+ EffectBrush returnBrush = new RadialEffectBrush(newSpectrum);
+ returnBrush.SampleWindowSize = SampleWindowSize * (float)(1.0 - percent) + otherBrush.SampleWindowSize * (float)percent;
+
+ return returnBrush;
+ }
+ }
+}
diff --git a/Project-Aurora/ColorBox/packages.config b/Project-Aurora/ColorBox/packages.config
new file mode 100644
index 000000000..0fa4e0151
--- /dev/null
+++ b/Project-Aurora/ColorBox/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/Project-Aurora/Project-Aurora/Controls/Control_FieldPresenter.xaml.cs b/Project-Aurora/Project-Aurora/Controls/Control_FieldPresenter.xaml.cs
index d6132e83c..4cb2a4301 100644
--- a/Project-Aurora/Project-Aurora/Controls/Control_FieldPresenter.xaml.cs
+++ b/Project-Aurora/Project-Aurora/Controls/Control_FieldPresenter.xaml.cs
@@ -86,7 +86,7 @@ public object Value {
// Gradient colour
{ typeof(Settings.LayerEffectConfig), bind => new Control_GradientEditor((Settings.LayerEffectConfig)((Control_FieldPresenter)bind.Source).Value) },
- { typeof(EffectsEngine.EffectBrush), bind => new ColorBox.ColorBox().SetBindingChain(ColorBox.ColorBox.BrushProperty, bind, new EffectBrushToBrushConverter(), BindingMode.TwoWay) },
+ { typeof(EffectsEngine.EffectBrush), bind => new ColorBox.ColorBox().SetBindingChain(ColorBox.ColorBox.BrushProperty, bind, bindingMode: BindingMode.TwoWay) },
// KeySequences
{ typeof(Settings.KeySequence), bind => new Controls.KeySequence {
diff --git a/Project-Aurora/Project-Aurora/Controls/Control_GradientEditor.xaml b/Project-Aurora/Project-Aurora/Controls/Control_GradientEditor.xaml
index 00e8e0420..8ae32b437 100644
--- a/Project-Aurora/Project-Aurora/Controls/Control_GradientEditor.xaml
+++ b/Project-Aurora/Project-Aurora/Controls/Control_GradientEditor.xaml
@@ -9,10 +9,7 @@
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
d:DesignHeight="160" d:DesignWidth="240">
-
-
-
-
+
@@ -29,17 +26,14 @@
-
-
-
-
+
-
+
-
+
-
+
diff --git a/Project-Aurora/Project-Aurora/Controls/Control_GradientEditor.xaml.cs b/Project-Aurora/Project-Aurora/Controls/Control_GradientEditor.xaml.cs
index 5fcb0cf0d..6e8a11a96 100644
--- a/Project-Aurora/Project-Aurora/Controls/Control_GradientEditor.xaml.cs
+++ b/Project-Aurora/Project-Aurora/Controls/Control_GradientEditor.xaml.cs
@@ -11,7 +11,6 @@ public partial class Control_GradientEditor : UserControl {
public Control_GradientEditor(LayerEffectConfig gradient) {
InitializeComponent();
- animTypeCb.ItemsSource = Utils.EnumUtils.GetEnumItemsSource();
DataContext = gradient;
}
}
diff --git a/Project-Aurora/Project-Aurora/Controls/EffectSettingsWindow.xaml b/Project-Aurora/Project-Aurora/Controls/EffectSettingsWindow.xaml
index 2c9becd27..0df744df6 100644
--- a/Project-Aurora/Project-Aurora/Controls/EffectSettingsWindow.xaml
+++ b/Project-Aurora/Project-Aurora/Controls/EffectSettingsWindow.xaml
@@ -10,21 +10,6 @@
xmlns:ncore="http://schemas.ncore.com/wpf/xaml/colorbox" x:Class="Aurora.Controls.EffectSettingsWindow"
xmlns:eff_config="clr-namespace:Aurora.Settings"
mc:Ignorable="d" ShowInTaskbar="False" ResizeMode="NoResize" Title="Effect Settings" Height="260" Width="440" Topmost="True" WindowStartupLocation="CenterOwner" Activated="Window_Activated" Deactivated="Window_Deactivated" Background="Transparent">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -40,8 +25,6 @@
-
-
-
+
diff --git a/Project-Aurora/Project-Aurora/Controls/EffectSettingsWindow.xaml.cs b/Project-Aurora/Project-Aurora/Controls/EffectSettingsWindow.xaml.cs
index 3099c6b5b..04267c2ad 100644
--- a/Project-Aurora/Project-Aurora/Controls/EffectSettingsWindow.xaml.cs
+++ b/Project-Aurora/Project-Aurora/Controls/EffectSettingsWindow.xaml.cs
@@ -27,17 +27,9 @@ public EffectSettingsWindow()
this.effect_speed_slider.Value = EffectConfig.speed;
this.effect_speed_label.Text = "x " + EffectConfig.speed;
this.effect_angle.Text = EffectConfig.angle.ToString();
- Brush brush = EffectConfig.brush.GetMediaBrush();
- try
- {
- this.gradient_editor.Brush = brush;
- }
- catch (Exception exc)
- {
- Global.logger.Error("Could not set brush, exception: " + exc);
- //this.gradient_editor.Brush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0, 0));
- }
+ this.gradient_editor.Brush = EffectConfig.brush;
+
this.gradient_editor.BrushChanged += Gradient_editor_BrushChanged;
}
@@ -52,26 +44,15 @@ public EffectSettingsWindow(LayerEffectConfig EffectConfig)
this.effect_speed_slider.Value = EffectConfig.speed;
this.effect_speed_label.Text = "x " + EffectConfig.speed;
this.effect_angle.Text = EffectConfig.angle.ToString();
- this.effect_animation_type.SelectedIndex = (int)EffectConfig.animation_type;
this.effect_animation_reversed.IsChecked = EffectConfig.animation_reverse;
- Brush brush = EffectConfig.brush.GetMediaBrush();
- try
- {
- this.gradient_editor.Brush = brush;
- }
- catch(Exception exc)
- {
- Global.logger.Error("Could not set brush, exception: " + exc);
-
- //this.gradient_editor.Brush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0, 0));
- }
+ this.gradient_editor.Brush = EffectConfig.brush;
this.gradient_editor.BrushChanged += Gradient_editor_BrushChanged;
}
private void Gradient_editor_BrushChanged(object sender, ColorBox.BrushChangedEventArgs e)
{
- EffectConfig.brush = new EffectsEngine.EffectBrush(this.gradient_editor.Brush);
+ EffectConfig.brush = this.gradient_editor.Brush;
}
private void FireEffectConfigUpdated()
@@ -80,7 +61,7 @@ private void FireEffectConfigUpdated()
EffectConfigUpdated(this, new EventArgs());
}
-
+
private void effect_speed_slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
{
if (this.IsLoaded)
@@ -115,7 +96,7 @@ private void secondary_color_SelectedColorChanged(object sender, RoutedPropertyC
private void accept_button_Click(object sender, RoutedEventArgs e)
{
- EffectConfig.brush = new EffectsEngine.EffectBrush(this.gradient_editor.Brush);
+ EffectConfig.brush = this.gradient_editor.Brush;
FireEffectConfigUpdated();
Close();
}
@@ -150,14 +131,6 @@ private void effect_angle_ValueChanged(object sender, RoutedPropertyChangedEvent
}
}
- private void effect_animation_type_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (IsLoaded)
- {
- EffectConfig.animation_type = (AnimationType)Enum.Parse(typeof(AnimationType),effect_animation_type.SelectedIndex.ToString());
- }
- }
-
private void effect_animation_reversed_Checked(object sender, RoutedEventArgs e)
{
if (IsLoaded)
diff --git a/Project-Aurora/Project-Aurora/EffectsEngine/Animations/AnimationFilledGradientRectangle.cs b/Project-Aurora/Project-Aurora/EffectsEngine/Animations/AnimationFilledGradientRectangle.cs
index 3823b2237..09f9b461b 100644
--- a/Project-Aurora/Project-Aurora/EffectsEngine/Animations/AnimationFilledGradientRectangle.cs
+++ b/Project-Aurora/Project-Aurora/EffectsEngine/Animations/AnimationFilledGradientRectangle.cs
@@ -37,9 +37,7 @@ public AnimationFilledGradientRectangle(float x, float y, float rect_width, floa
PointF rotatePoint = new PointF(_scaledDimension.X, _scaledDimension.Y);
- EffectBrush _newbrush = new EffectBrush(_gradientBrush);
- _newbrush.start = new PointF(_newbrush.start.X * scale, _newbrush.start.Y * scale);
- _newbrush.end = new PointF(_newbrush.end.X * scale, _newbrush.end.Y * scale);
+ EffectBrush _newbrush = (EffectBrush)_gradientBrush.Clone();
Matrix rotationMatrix = new Matrix();
rotationMatrix.RotateAt(-_angle, rotatePoint, MatrixOrder.Append);
@@ -79,7 +77,7 @@ public override AnimationFrame GetCopy()
_dimension.Height
);
- return new AnimationFilledGradientRectangle(newrect, new EffectBrush(_gradientBrush), _duration).SetAngle(_angle).SetTransitionType(_transitionType);
+ return new AnimationFilledGradientRectangle(newrect, (EffectBrush)_gradientBrush.Clone(), _duration).SetAngle(_angle).SetTransitionType(_transitionType);
}
public override bool Equals(object obj)
diff --git a/Project-Aurora/Project-Aurora/EffectsEngine/Animations/AnimationGradientCircle.cs b/Project-Aurora/Project-Aurora/EffectsEngine/Animations/AnimationGradientCircle.cs
index 0560bb3ad..8e3d35b62 100644
--- a/Project-Aurora/Project-Aurora/EffectsEngine/Animations/AnimationGradientCircle.cs
+++ b/Project-Aurora/Project-Aurora/EffectsEngine/Animations/AnimationGradientCircle.cs
@@ -41,14 +41,11 @@ public AnimationGradientCircle(float x, float y, float radius, EffectBrush brush
RectangleF _scaledDimension = new RectangleF(_dimension.X * scale, _dimension.Y * scale, _dimension.Width * scale, _dimension.Height * scale);
_scaledDimension.Offset(offset);
- EffectBrush _newbrush = new EffectBrush(_gradientBrush);
- _newbrush.start = new PointF(0.0f, 0.0f);
- _newbrush.end = new PointF(1.0f, 1.0f);
- _newbrush.center = new PointF(0.5f, 0.5f);
+ EffectBrush _newbrush = new RadialEffectBrush(_gradientBrush);
SortedDictionary newColorGradients = new SortedDictionary();
- ColorSpectrum spectrum = _newbrush.GetColorSpectrum();
- var colors = _newbrush.colorGradients;
+ ColorBox.ColorSpectrum spectrum = _newbrush.GetColorSpectrum();
+ var colors = _newbrush.ColorGradients;
float _cutOffPoint = _width / _radius;
@@ -62,7 +59,7 @@ public AnimationGradientCircle(float x, float y, float radius, EffectBrush brush
newColorGradients.Add(_cutOffPoint - 0.0001f, Color.Transparent);
newColorGradients.Add(0.0f, Color.Transparent);
- _newbrush.colorGradients = newColorGradients;
+ _newbrush.ColorGradients = newColorGradients;
}
else if (_cutOffPoint > 1.0f)
{
@@ -77,7 +74,6 @@ public AnimationGradientCircle(float x, float y, float radius, EffectBrush brush
newColorGradients.Add(0.0f, spectrum.GetColorAt((1 - 1 / _cutOffPoint)));
}
- _newbrush.SetBrushType(EffectBrush.BrushType.Radial);
Brush brush = _newbrush.GetDrawingBrush();
if(brush is PathGradientBrush)
@@ -124,7 +120,7 @@ public override AnimationFrame GetCopy()
_dimension.Height
);
- return new AnimationGradientCircle(newrect, new EffectBrush(_gradientBrush), _width, _duration).SetAngle(_angle).SetTransitionType(_transitionType);
+ return new AnimationGradientCircle(newrect, (EffectBrush)_gradientBrush.Clone(), _width, _duration).SetAngle(_angle).SetTransitionType(_transitionType);
}
public override bool Equals(object obj)
diff --git a/Project-Aurora/Project-Aurora/EffectsEngine/EffectBrush.cs b/Project-Aurora/Project-Aurora/EffectsEngine/EffectBrush.cs
deleted file mode 100644
index fab2d4c20..000000000
--- a/Project-Aurora/Project-Aurora/EffectsEngine/EffectBrush.cs
+++ /dev/null
@@ -1,645 +0,0 @@
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-
-namespace Aurora.EffectsEngine
-{
- public class EffectBrush
- {
- public enum BrushType
- {
- None,
- Solid,
- Linear,
- Radial
- };
-
- public enum BrushWrap
- {
- None,
- Repeat,
- Reflect
- };
-
- public BrushType type = BrushType.None;
- public BrushWrap wrap = BrushWrap.None;
- [JsonProperty("color_gradients")]
- public SortedDictionary colorGradients = new SortedDictionary();
- public System.Drawing.PointF start;
- public System.Drawing.PointF end;
- public System.Drawing.PointF center;
-
- private System.Drawing.Brush _drawingBrush = null;
- private System.Windows.Media.Brush _mediaBrush = null;
-
- public EffectBrush()
- {
- type = BrushType.Solid;
-
- colorGradients.Add(0.0f, System.Drawing.Color.Red);
- colorGradients.Add(1.0f, System.Drawing.Color.Blue);
-
- start = new System.Drawing.PointF(0, 0);
- end = new System.Drawing.PointF(1, 0);
- center = new System.Drawing.PointF(0.0f, 0.0f);
- }
-
- public EffectBrush(EffectBrush otherBrush)
- {
- this.type = otherBrush.type;
- this.wrap = otherBrush.wrap;
- this.colorGradients = otherBrush.colorGradients;
- this.start = otherBrush.start;
- this.end = otherBrush.end;
- this.center = otherBrush.center;
- }
-
- public EffectBrush(ColorSpectrum spectrum)
- {
- type = BrushType.Linear;
-
- foreach(var color in spectrum.GetSpectrumColors())
- colorGradients.Add(color.Key, color.Value);
-
- start = new System.Drawing.PointF(0, 0);
- end = new System.Drawing.PointF(1, 0);
- center = new System.Drawing.PointF(0.0f, 0.0f);
- }
-
- public EffectBrush(System.Drawing.Brush brush)
- {
- if (brush is System.Drawing.SolidBrush)
- {
- type = BrushType.Solid;
-
- colorGradients.Add(0.0f, (brush as System.Drawing.SolidBrush).Color);
- colorGradients.Add(1.0f, (brush as System.Drawing.SolidBrush).Color);
-
- wrap = BrushWrap.Repeat;
- }
- else if (brush is System.Drawing.Drawing2D.LinearGradientBrush)
- {
- type = BrushType.Linear;
-
- System.Drawing.Drawing2D.LinearGradientBrush lgb = (brush as System.Drawing.Drawing2D.LinearGradientBrush);
-
- start = lgb.Rectangle.Location;
- end = new System.Drawing.PointF(lgb.Rectangle.Width, lgb.Rectangle.Height);
- center = new System.Drawing.PointF(0.0f, 0.0f);
-
- switch (lgb.WrapMode)
- {
- case (System.Drawing.Drawing2D.WrapMode.Clamp):
- wrap = BrushWrap.None;
- break;
- case (System.Drawing.Drawing2D.WrapMode.Tile):
- wrap = BrushWrap.Repeat;
- break;
- case (System.Drawing.Drawing2D.WrapMode.TileFlipXY):
- wrap = BrushWrap.Reflect;
- break;
- }
-
- try
- {
- if (lgb.InterpolationColors != null && lgb.InterpolationColors.Colors.Length == lgb.InterpolationColors.Positions.Length)
- {
- for (int x = 0; x < lgb.InterpolationColors.Colors.Length; x++)
- {
- if (!colorGradients.ContainsKey(lgb.InterpolationColors.Positions[x]) && (lgb.InterpolationColors.Positions[x] >= 0.0f && lgb.InterpolationColors.Positions[x] <= 1.0f))
- colorGradients.Add(
- lgb.InterpolationColors.Positions[x],
- lgb.InterpolationColors.Colors[x]
- );
- }
- }
- }
- catch (Exception exc)
- {
- colorGradients.Clear();
-
- for (int x = 0; x < lgb.LinearColors.Length; x++)
- {
- float pos = x / (float)(lgb.LinearColors.Length - 1);
-
- if (!colorGradients.ContainsKey(pos))
- colorGradients.Add(
- pos,
- lgb.LinearColors[x]
- );
- }
- }
- }
- else if (brush is System.Drawing.Drawing2D.PathGradientBrush)
- {
- type = BrushType.Radial;
-
- System.Drawing.Drawing2D.PathGradientBrush pgb = (brush as System.Drawing.Drawing2D.PathGradientBrush);
-
- start = pgb.Rectangle.Location;
- end = new System.Drawing.PointF(pgb.Rectangle.Width, pgb.Rectangle.Height);
- center = new System.Drawing.PointF(
- pgb.CenterPoint.X,
- pgb.CenterPoint.Y
- );
-
-
- switch (pgb.WrapMode)
- {
- case (System.Drawing.Drawing2D.WrapMode.Clamp):
- wrap = BrushWrap.None;
- break;
- case (System.Drawing.Drawing2D.WrapMode.Tile):
- wrap = BrushWrap.Repeat;
- break;
- case (System.Drawing.Drawing2D.WrapMode.TileFlipXY):
- wrap = BrushWrap.Reflect;
- break;
- }
-
- try
- {
- if (pgb.InterpolationColors != null && pgb.InterpolationColors.Colors.Length == pgb.InterpolationColors.Positions.Length)
- {
- for (int x = 0; x < pgb.InterpolationColors.Colors.Length; x++)
- {
- if (!colorGradients.ContainsKey(pgb.InterpolationColors.Positions[x]) && (pgb.InterpolationColors.Positions[x] >= 0.0f && pgb.InterpolationColors.Positions[x] <= 1.0f))
- colorGradients.Add(
- pgb.InterpolationColors.Positions[x],
- pgb.InterpolationColors.Colors[x]
- );
- }
- }
- }
- catch (Exception exc)
- {
- colorGradients.Clear();
-
- for (int x = 0; x < pgb.SurroundColors.Length; x++)
- {
- float pos = x / (float)(pgb.SurroundColors.Length - 1);
-
- if (!colorGradients.ContainsKey(pos))
- colorGradients.Add(
- pos,
- pgb.SurroundColors[x]
- );
- }
- }
- }
- else
- {
-
- }
-
- if(colorGradients.Count > 0)
- {
- bool firstFound = false;
- System.Drawing.Color first_color = new System.Drawing.Color();
- System.Drawing.Color last_color = new System.Drawing.Color();
-
- foreach(var kvp in colorGradients)
- {
- if(!firstFound)
- {
- first_color = kvp.Value;
- firstFound = true;
- }
-
- last_color = kvp.Value;
- }
-
- if (!colorGradients.ContainsKey(0.0f))
- colorGradients.Add(0.0f, first_color);
-
- if (!colorGradients.ContainsKey(1.0f))
- colorGradients.Add(1.0f, last_color);
- }
- else
- {
- if (!colorGradients.ContainsKey(0.0f))
- colorGradients.Add(0.0f, System.Drawing.Color.Transparent);
-
- if (!colorGradients.ContainsKey(1.0f))
- colorGradients.Add(1.0f, System.Drawing.Color.Transparent);
- }
-
-
- }
-
- public EffectBrush(System.Windows.Media.Brush brush)
- {
- if (brush is System.Windows.Media.SolidColorBrush)
- {
- type = BrushType.Solid;
-
- wrap = BrushWrap.Repeat;
-
- colorGradients.Add(0.0f, Utils.ColorUtils.MediaColorToDrawingColor((brush as System.Windows.Media.SolidColorBrush).Color));
- colorGradients.Add(1.0f, Utils.ColorUtils.MediaColorToDrawingColor((brush as System.Windows.Media.SolidColorBrush).Color));
- }
- else if (brush is System.Windows.Media.LinearGradientBrush)
- {
- type = BrushType.Linear;
-
- System.Windows.Media.LinearGradientBrush lgb = (brush as System.Windows.Media.LinearGradientBrush);
-
- start = new System.Drawing.PointF((float)lgb.StartPoint.X, (float)lgb.StartPoint.Y);
- end = new System.Drawing.PointF((float)lgb.EndPoint.X, (float)lgb.EndPoint.Y);
- center = new System.Drawing.PointF(0.0f, 0.0f);
-
- switch (lgb.SpreadMethod)
- {
- case (System.Windows.Media.GradientSpreadMethod.Pad):
- wrap = BrushWrap.None;
- break;
- case (System.Windows.Media.GradientSpreadMethod.Repeat):
- wrap = BrushWrap.Repeat;
- break;
- case (System.Windows.Media.GradientSpreadMethod.Reflect):
- wrap = BrushWrap.Reflect;
- break;
- }
-
- foreach (var grad in lgb.GradientStops)
- {
- if (!colorGradients.ContainsKey((float)grad.Offset) && ((float)grad.Offset >= 0.0f && (float)grad.Offset <= 1.0f))
- colorGradients.Add(
- (float)grad.Offset,
- Utils.ColorUtils.MediaColorToDrawingColor(grad.Color)
- );
- }
- }
- else if (brush is System.Windows.Media.RadialGradientBrush)
- {
- type = BrushType.Radial;
-
- System.Windows.Media.RadialGradientBrush rgb = (brush as System.Windows.Media.RadialGradientBrush);
-
- start = new System.Drawing.PointF(0, 0);
- end = new System.Drawing.PointF((float)rgb.RadiusX * 2.0f, (float)rgb.RadiusY * 2.0f);
- center = new System.Drawing.PointF(
- (float)rgb.Center.X,
- (float)rgb.Center.Y
- );
-
- switch (rgb.SpreadMethod)
- {
- case (System.Windows.Media.GradientSpreadMethod.Pad):
- wrap = BrushWrap.None;
- break;
- case (System.Windows.Media.GradientSpreadMethod.Repeat):
- wrap = BrushWrap.Repeat;
- break;
- case (System.Windows.Media.GradientSpreadMethod.Reflect):
- wrap = BrushWrap.Reflect;
- break;
- }
-
- foreach (var grad in rgb.GradientStops)
- {
- if (!colorGradients.ContainsKey((float)grad.Offset) && ((float)grad.Offset >= 0.0f && (float)grad.Offset <= 1.0f))
- colorGradients.Add(
- (float)grad.Offset,
- Utils.ColorUtils.MediaColorToDrawingColor(grad.Color)
- );
- }
- }
- else
- {
-
- }
-
- if (colorGradients.Count > 0)
- {
- bool firstFound = false;
- System.Drawing.Color first_color = new System.Drawing.Color();
- System.Drawing.Color last_color = new System.Drawing.Color();
-
- foreach (var kvp in colorGradients)
- {
- if (!firstFound)
- {
- first_color = kvp.Value;
- firstFound = true;
- }
-
- last_color = kvp.Value;
- }
-
- if (!colorGradients.ContainsKey(0.0f))
- colorGradients.Add(0.0f, first_color);
-
- if (!colorGradients.ContainsKey(1.0f))
- colorGradients.Add(1.0f, last_color);
- }
- else
- {
- if (!colorGradients.ContainsKey(0.0f))
- colorGradients.Add(0.0f, System.Drawing.Color.Transparent);
-
- if (!colorGradients.ContainsKey(1.0f))
- colorGradients.Add(1.0f, System.Drawing.Color.Transparent);
- }
- }
-
- public EffectBrush SetBrushType(BrushType type)
- {
- this.type = type;
- return this;
- }
-
- public EffectBrush SetWrap(BrushWrap wrap)
- {
- this.wrap = wrap;
- return this;
- }
-
- public System.Drawing.Brush GetDrawingBrush()
- {
- if (true/*_drawingbrush == null*/)
- {
- if (type == BrushType.Solid)
- {
- _drawingBrush = new System.Drawing.SolidBrush(colorGradients[0.0f]);
- }
- else if (type == BrushType.Linear)
- {
- System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(
- start,
- end,
- System.Drawing.Color.Red,
- System.Drawing.Color.Red
- );
-
- List brush_colors = new List();
- List brush_positions = new List();
-
- foreach (var kvp in colorGradients)
- {
- brush_positions.Add(kvp.Key);
- brush_colors.Add(kvp.Value);
- }
-
- System.Drawing.Drawing2D.ColorBlend color_blend = new System.Drawing.Drawing2D.ColorBlend();
- color_blend.Colors = brush_colors.ToArray();
- color_blend.Positions = brush_positions.ToArray();
- brush.InterpolationColors = color_blend;
-
- switch (wrap)
- {
- //case BrushWrap.None:
- // brush.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp;
- // break;
- case BrushWrap.Repeat:
- brush.WrapMode = System.Drawing.Drawing2D.WrapMode.Tile;
- break;
- case BrushWrap.Reflect:
- brush.WrapMode = System.Drawing.Drawing2D.WrapMode.TileFlipXY;
- break;
- }
-
- _drawingBrush = brush;
- }
- else if (type == BrushType.Radial)
- {
- System.Drawing.Drawing2D.GraphicsPath g_path = new System.Drawing.Drawing2D.GraphicsPath();
- g_path.AddEllipse(
- new System.Drawing.RectangleF(
- start.X,
- start.Y,
- end.X,
- end.Y
- ));
-
- System.Drawing.Drawing2D.PathGradientBrush brush = new System.Drawing.Drawing2D.PathGradientBrush(
- g_path
- );
-
- switch (wrap)
- {
- //// Clamp causes an exception, it's a bug in the Drawing Brush.
- //case BrushWrap.None:
- // brush.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp;
- // break;
- case BrushWrap.Repeat:
- brush.WrapMode = System.Drawing.Drawing2D.WrapMode.Tile;
- break;
- case BrushWrap.Reflect:
- brush.WrapMode = System.Drawing.Drawing2D.WrapMode.TileFlipXY;
- break;
- }
-
- List brush_colors = new List();
- List brush_positions = new List();
-
- foreach (var kvp in colorGradients)
- {
- brush_positions.Add(1.0f - kvp.Key);
- brush_colors.Add(kvp.Value);
- }
-
- brush.CenterPoint = center;
- //brush.CenterColor = brush_colors[0];
-
- //brush.SurroundColors = brush_colors.ToArray();
-
- brush_colors.Reverse();
- brush_positions.Reverse();
-
- System.Drawing.Drawing2D.ColorBlend color_blend = new System.Drawing.Drawing2D.ColorBlend();
- color_blend.Colors = brush_colors.ToArray();
- color_blend.Positions = brush_positions.ToArray();
- brush.InterpolationColors = color_blend;
-
- _drawingBrush = brush;
- }
- else
- {
- _drawingBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Transparent);
- }
- }
-
- return _drawingBrush;
- }
-
- public System.Windows.Media.Brush GetMediaBrush()
- {
- if (_mediaBrush == null)
- {
- if (type == BrushType.Solid)
- {
- System.Windows.Media.SolidColorBrush brush = new System.Windows.Media.SolidColorBrush(
- Utils.ColorUtils.DrawingColorToMediaColor(colorGradients[0.0f])
- );
- brush.Freeze();
-
- _mediaBrush = brush;
- }
- else if (type == BrushType.Linear)
- {
- System.Windows.Media.GradientStopCollection collection = new System.Windows.Media.GradientStopCollection();
-
- foreach (var kvp in colorGradients)
- {
- collection.Add(
- new System.Windows.Media.GradientStop(
- Utils.ColorUtils.DrawingColorToMediaColor(kvp.Value),
- kvp.Key)
- );
- }
-
- System.Windows.Media.LinearGradientBrush brush = new System.Windows.Media.LinearGradientBrush(collection);
- brush.StartPoint = new System.Windows.Point(start.X, start.Y);
- brush.EndPoint = new System.Windows.Point(end.X, end.Y);
-
- switch (wrap)
- {
- case BrushWrap.None:
- brush.SpreadMethod = System.Windows.Media.GradientSpreadMethod.Pad;
- break;
- case BrushWrap.Repeat:
- brush.SpreadMethod = System.Windows.Media.GradientSpreadMethod.Repeat;
- break;
- case BrushWrap.Reflect:
- brush.SpreadMethod = System.Windows.Media.GradientSpreadMethod.Reflect;
- break;
- }
-
- _mediaBrush = brush;
- }
- else if (type == BrushType.Radial)
- {
- System.Windows.Media.GradientStopCollection collection = new System.Windows.Media.GradientStopCollection();
-
- foreach (var kvp in colorGradients)
- {
- collection.Add(
- new System.Windows.Media.GradientStop(
- Utils.ColorUtils.DrawingColorToMediaColor(kvp.Value),
- kvp.Key)
- );
- }
-
- System.Windows.Media.RadialGradientBrush brush = new System.Windows.Media.RadialGradientBrush(collection);
- brush.Center = new System.Windows.Point(center.X, center.Y);
- brush.RadiusX = end.X / 2.0;
- brush.RadiusY = end.Y / 2.0;
-
- switch (wrap)
- {
- case BrushWrap.None:
- brush.SpreadMethod = System.Windows.Media.GradientSpreadMethod.Pad;
- break;
- case BrushWrap.Repeat:
- brush.SpreadMethod = System.Windows.Media.GradientSpreadMethod.Repeat;
- break;
- case BrushWrap.Reflect:
- brush.SpreadMethod = System.Windows.Media.GradientSpreadMethod.Reflect;
- break;
- }
-
- _mediaBrush = brush;
- }
- else
- {
- System.Windows.Media.SolidColorBrush brush = new System.Windows.Media.SolidColorBrush(
- System.Windows.Media.Color.FromArgb(255, 255, 0, 0)
- );
- brush.Freeze();
-
- _mediaBrush = brush;
- }
- }
-
- return _mediaBrush;
- }
-
- public ColorSpectrum GetColorSpectrum()
- {
- ColorSpectrum spectrum = new ColorSpectrum();
-
- if(type == BrushType.Solid)
- {
- spectrum = new ColorSpectrum(colorGradients[0.0f]);
- }
- else
- {
- foreach (var color in colorGradients)
- spectrum.SetColorAt(color.Key, color.Value);
- }
-
- return spectrum;
- }
-
- ///
- /// Blends two EffectBrushes together by a specified amount
- ///
- /// The foreground EffectBrush (When percent is at 1.0D, only this EffectBrush is shown)
- /// The blending percent value
- /// The blended EffectBrush
- public EffectBrush BlendEffectBrush(EffectBrush otherBrush, double percent)
- {
- if (percent <= 0.0)
- return new EffectBrush(this);
- else if (percent >= 1.0)
- return new EffectBrush(otherBrush);
-
- ColorSpectrum currentSpectrum = new ColorSpectrum(GetColorSpectrum());
- ColorSpectrum newSpectrum = new ColorSpectrum(currentSpectrum).MultiplyByScalar(1.0 - percent);
-
- foreach (var kvp in otherBrush.colorGradients)
- {
- System.Drawing.Color bgColor = currentSpectrum.GetColorAt(kvp.Key);
- System.Drawing.Color fgColor = kvp.Value;
-
- newSpectrum.SetColorAt(kvp.Key, Utils.ColorUtils.BlendColors(bgColor, fgColor, percent));
- }
-
- EffectBrush returnBrush = new EffectBrush(newSpectrum);
- returnBrush.SetBrushType(type).SetWrap(wrap);
-
- returnBrush.start = new System.Drawing.PointF((float)(start.X * (1.0 - percent) + otherBrush.start.X * (percent)), (float)(start.Y * (1.0 - percent) + otherBrush.start.Y * (percent)));
- returnBrush.end = new System.Drawing.PointF((float)(end.X * (1.0 - percent) + otherBrush.end.X * (percent)), (float)(end.Y * (1.0 - percent) + otherBrush.end.Y * (percent)));
- returnBrush.center = new System.Drawing.PointF((float)(center.X * (1.0 - percent) + otherBrush.center.X * (percent)), (float)(center.Y * (1.0 - percent) + otherBrush.center.Y * (percent)));
-
- return returnBrush;
- }
-
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj)) return false;
- if (ReferenceEquals(this, obj)) return true;
- if (obj.GetType() != this.GetType()) return false;
- return Equals((EffectBrush)obj);
- }
-
- public bool Equals(EffectBrush p)
- {
- if (ReferenceEquals(null, p)) return false;
- if (ReferenceEquals(this, p)) return true;
-
- return (type == p.type &&
- wrap == p.wrap &&
- colorGradients.Equals(p.colorGradients) &&
- start.Equals(p.start) &&
- end.Equals(p.end) &&
- center.Equals(p.center));
- }
-
- public override int GetHashCode()
- {
- unchecked
- {
- int hash = 17;
- hash = hash * 23 + type.GetHashCode();
- hash = hash * 23 + wrap.GetHashCode();
- hash = hash * 23 + colorGradients.GetHashCode();
- hash = hash * 23 + start.GetHashCode();
- hash = hash * 23 + end.GetHashCode();
- hash = hash * 23 + center.GetHashCode();
- return hash;
- }
- }
- }
-}
diff --git a/Project-Aurora/Project-Aurora/EffectsEngine/EffectLayer.cs b/Project-Aurora/Project-Aurora/EffectsEngine/EffectLayer.cs
index f3b54fe36..de36d31fd 100755
--- a/Project-Aurora/Project-Aurora/EffectsEngine/EffectLayer.cs
+++ b/Project-Aurora/Project-Aurora/EffectsEngine/EffectLayer.cs
@@ -30,7 +30,7 @@ public class EffectLayer : IDisposable
Devices.DeviceKeys.Peripheral_Logo
};
- static private ColorSpectrum rainbow = new ColorSpectrum(ColorSpectrum.RainbowLoop);
+ static private ColorBox.ColorSpectrum rainbow = new ColorBox.ColorSpectrum(ColorBox.ColorSpectrum.RainbowLoop);
///
/// Creates a new instance of the EffectLayer class with default parameters.
@@ -99,7 +99,7 @@ public EffectLayer(string name, Color color)
peripheral = new Color();
Brush brush;
float shift = 0.0f;
-
+ var brushRect = !rect.IsEmpty ? new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height) : new Rectangle(0, 0, Effects.canvas_width, Effects.canvas_height);
switch (effect)
{
case LayerEffects.ColorOverlay:
@@ -114,8 +114,7 @@ public EffectLayer(string name, Color color)
effect_config.shift_amount += ((Utils.Time.GetMillisecondsSinceEpoch() - effect_config.last_effect_call) / 1000.0f) * 5.0f * effect_config.speed;
effect_config.shift_amount = effect_config.shift_amount % Effects.canvas_biggest;
- if (effect_config.animation_type == AnimationType.Translate_XY)
- shift = effect_config.shift_amount;
+ shift = effect_config.shift_amount;
if (effect_config.animation_reverse)
shift *= -1.0f;
@@ -132,8 +131,7 @@ public EffectLayer(string name, Color color)
effect_config.shift_amount += ((Utils.Time.GetMillisecondsSinceEpoch() - effect_config.last_effect_call) / 1000.0f) * 5.0f * effect_config.speed;
effect_config.shift_amount = effect_config.shift_amount % Effects.canvas_biggest;
- if (effect_config.animation_type == AnimationType.Translate_XY)
- shift = effect_config.shift_amount;
+ shift = effect_config.shift_amount;
if (effect_config.animation_reverse)
shift *= -1.0f;
@@ -150,8 +148,7 @@ public EffectLayer(string name, Color color)
effect_config.shift_amount += ((Utils.Time.GetMillisecondsSinceEpoch() - effect_config.last_effect_call) / 1000.0f) * 5.0f * effect_config.speed;
effect_config.shift_amount = effect_config.shift_amount % Effects.canvas_biggest;
- if (effect_config.animation_type == AnimationType.Translate_XY)
- shift = effect_config.shift_amount;
+ shift = effect_config.shift_amount;
if (effect_config.animation_reverse)
shift *= -1.0f;
@@ -168,8 +165,7 @@ public EffectLayer(string name, Color color)
effect_config.shift_amount += ((Utils.Time.GetMillisecondsSinceEpoch() - effect_config.last_effect_call) / 1000.0f) * 5.0f * effect_config.speed;
effect_config.shift_amount = effect_config.shift_amount % Effects.canvas_biggest;
- if (effect_config.animation_type == AnimationType.Translate_XY)
- shift = effect_config.shift_amount;
+ shift = effect_config.shift_amount;
if (effect_config.animation_reverse)
shift *= -1.0f;
@@ -187,8 +183,7 @@ public EffectLayer(string name, Color color)
effect_config.shift_amount = effect_config.shift_amount % Effects.canvas_biggest;
- if (effect_config.animation_type == AnimationType.Translate_XY)
- shift = effect_config.shift_amount;
+ shift = effect_config.shift_amount;
if (effect_config.animation_reverse)
shift *= -1.0f;
@@ -205,74 +200,12 @@ public EffectLayer(string name, Color color)
effect_config.shift_amount += ((Utils.Time.GetMillisecondsSinceEpoch() - effect_config.last_effect_call) / 1000.0f) * 0.067f * effect_config.speed;
effect_config.shift_amount = effect_config.shift_amount % Effects.canvas_biggest;
- if (effect_config.animation_type == AnimationType.Translate_XY)
- shift = effect_config.shift_amount;
- else if (effect_config.animation_type == AnimationType.Zoom_in && effect_config.brush.type == EffectBrush.BrushType.Radial)
- shift = ((Effects.canvas_biggest - effect_config.shift_amount) * 40.0f) % Effects.canvas_biggest;
- else if (effect_config.animation_type == AnimationType.Zoom_out && effect_config.brush.type == EffectBrush.BrushType.Radial)
- shift = (effect_config.shift_amount * 40.0f) % Effects.canvas_biggest;
+ shift = effect_config.shift_amount;
if (effect_config.animation_reverse)
shift *= -1.0f;
-
- brush = effect_config.brush.GetDrawingBrush();
- if (effect_config.brush.type == EffectBrush.BrushType.Linear)
- {
- if (!rect.IsEmpty)
- {
- (brush as LinearGradientBrush).TranslateTransform(rect.X, rect.Y);
- (brush as LinearGradientBrush).ScaleTransform(rect.Width * 100 / effect_config.gradient_size, rect.Height * 100 / effect_config.gradient_size);
- }
- else
- {
- (brush as LinearGradientBrush).ScaleTransform(Effects.canvas_height * 100 / effect_config.gradient_size, Effects.canvas_height * 100 / effect_config.gradient_size);
- }
-
- (brush as LinearGradientBrush).RotateTransform(effect_config.angle);
- (brush as LinearGradientBrush).TranslateTransform(shift, shift);
- }
- else if (effect_config.brush.type == EffectBrush.BrushType.Radial)
- {
- if (effect_config.animation_type == AnimationType.Zoom_in || effect_config.animation_type == AnimationType.Zoom_out)
- {
- float percent = shift / Effects.canvas_biggest;
-
- float x_offset = (Effects.canvas_width / 2.0f) * percent;
- float y_offset = (Effects.canvas_height / 2.0f) * percent;
-
-
- (brush as PathGradientBrush).WrapMode = WrapMode.Clamp;
-
- if (!rect.IsEmpty)
- {
- x_offset = (rect.Width / 2.0f) * percent;
- y_offset = (rect.Height / 2.0f) * percent;
-
- (brush as PathGradientBrush).TranslateTransform(rect.X + x_offset, rect.Y + y_offset);
- (brush as PathGradientBrush).ScaleTransform((rect.Width - (2.0f * x_offset)) * 100 / effect_config.gradient_size, (rect.Height - (2.0f * y_offset)) * 100 / effect_config.gradient_size);
- }
- else
- {
- (brush as PathGradientBrush).ScaleTransform((Effects.canvas_height + x_offset) * 100 / effect_config.gradient_size, (Effects.canvas_height + y_offset) * 100 / effect_config.gradient_size);
- }
- }
- else
- {
- if (!rect.IsEmpty)
- {
- (brush as PathGradientBrush).TranslateTransform(rect.X, rect.Y);
- (brush as PathGradientBrush).ScaleTransform(rect.Width * 100 / effect_config.gradient_size, rect.Height * 100 / effect_config.gradient_size);
- }
- else
- {
- (brush as PathGradientBrush).ScaleTransform(Effects.canvas_height * 100 / effect_config.gradient_size, Effects.canvas_height * 100 / effect_config.gradient_size);
- }
- }
-
- (brush as PathGradientBrush).RotateTransform(effect_config.angle);
-
- //(brush as PathGradientBrush).TranslateTransform(x_shift, y_shift);
- }
+ float percent = shift;
+ brush = effect_config.brush.GetDrawingBrush(percent % 1 , brushRect);
Fill(brush);
@@ -335,19 +268,6 @@ public EffectLayer Fill(Brush brush)
{
using (Graphics g = Graphics.FromImage(colormap))
{
- /*if(brush is PathGradientBrush)
- {
- GraphicsPath gp = new GraphicsPath();
- gp.AddEllipse((brush as PathGradientBrush).Rectangle);
-
- g.FillPath(brush, gp);
- }
- else
- {
- Rectangle rect = new Rectangle(0, 0, colormap.Width, colormap.Height);
- g.FillRectangle(brush, rect);
- }
- */
Rectangle rect = new Rectangle(0, 0, colormap.Width, colormap.Height);
g.FillRectangle(brush, rect);
needsRender = true;
@@ -799,7 +719,7 @@ public EffectLayer PercentEffect(Color foregroundColor, Color backgroundColor, S
/// The maxiumum progress value
/// The percent effect type
/// Itself
- public EffectLayer PercentEffect(ColorSpectrum spectrum, Settings.KeySequence sequence, double value, double total = 1.0D, PercentEffectType percentEffectType = PercentEffectType.Progressive, double flash_past = 0.0, bool flash_reversed = false, bool blink_background = false)
+ public EffectLayer PercentEffect(ColorBox.ColorSpectrum spectrum, Settings.KeySequence sequence, double value, double total = 1.0D, PercentEffectType percentEffectType = PercentEffectType.Progressive, double flash_past = 0.0, bool flash_reversed = false, bool blink_background = false)
{
if (sequence.type == KeySequenceType.Sequence)
PercentEffect(spectrum, sequence.keys.ToArray(), value, total, percentEffectType, flash_past, flash_reversed);
@@ -888,7 +808,7 @@ public EffectLayer PercentEffect(Color foregroundColor, Color backgroundColor, D
/// The maxiumum progress value
/// The percent effect type
/// Itself
- public EffectLayer PercentEffect(ColorSpectrum spectrum, Devices.DeviceKeys[] keys, double value, double total, PercentEffectType percentEffectType = PercentEffectType.Progressive, double flash_past = 0.0, bool flash_reversed = false)
+ public EffectLayer PercentEffect(ColorBox.ColorSpectrum spectrum, Devices.DeviceKeys[] keys, double value, double total, PercentEffectType percentEffectType = PercentEffectType.Progressive, double flash_past = 0.0, bool flash_reversed = false)
{
double progress_total = value / total;
if (progress_total < 0.0)
@@ -1022,7 +942,7 @@ public EffectLayer PercentEffect(Color foregroundColor, Color backgroundColor, S
/// The maxiumum progress value
/// The percent effect type
/// Itself
- public EffectLayer PercentEffect(ColorSpectrum spectrum, Settings.FreeFormObject freeform, double value, double total, PercentEffectType percentEffectType = PercentEffectType.Progressive, double flash_past = 0.0, bool flash_reversed = false)
+ public EffectLayer PercentEffect(ColorBox.ColorSpectrum spectrum, Settings.FreeFormObject freeform, double value, double total, PercentEffectType percentEffectType = PercentEffectType.Progressive, double flash_past = 0.0, bool flash_reversed = false)
{
double progress_total = value / total;
if (progress_total < 0.0)
diff --git a/Project-Aurora/Project-Aurora/Profiles/CloneHero/CloneHeroProfile.cs b/Project-Aurora/Project-Aurora/Profiles/CloneHero/CloneHeroProfile.cs
index 962274d5c..2643a4841 100644
--- a/Project-Aurora/Project-Aurora/Profiles/CloneHero/CloneHeroProfile.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/CloneHero/CloneHeroProfile.cs
@@ -53,33 +53,15 @@ public override void Reset()
secondary = Color.FromArgb(39, 73, 167),
speed = 3,
angle = 0,
- animation_type = AnimationType.Translate_XY,
animation_reverse = false,
brush =
- {
- type = EffectBrush.BrushType.Linear,
- wrap = EffectBrush.BrushWrap.Repeat,
- colorGradients = new SortedDictionary()
+ new LinearEffectBrush{
+ ColorGradients = new SortedDictionary()
{
{0, Color.FromArgb(9, 43, 83) },
{0.298960835f, Color.FromArgb(187, 18, 194) },
{0.685535133f, Color.FromArgb(17, 185, 217) },
{1, Color.FromArgb(9, 43, 83) }
- },
- start =
- {
- X = 0,
- Y = -0.5f
- },
- end =
- {
- X = 1,
- Y = 1
- },
- center =
- {
- X = 0,
- Y = 0
}
},
diff --git a/Project-Aurora/Project-Aurora/Profiles/Desktop/DesktopProfile.cs b/Project-Aurora/Project-Aurora/Profiles/Desktop/DesktopProfile.cs
index cd3ad8ff4..a9efd8dfa 100755
--- a/Project-Aurora/Project-Aurora/Profiles/Desktop/DesktopProfile.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Desktop/DesktopProfile.cs
@@ -45,10 +45,9 @@ private void setVolumeOverlay()
Devices.DeviceKeys.F5, Devices.DeviceKeys.F6, Devices.DeviceKeys.F7, Devices.DeviceKeys.F8,
Devices.DeviceKeys.F9, Devices.DeviceKeys.F10, Devices.DeviceKeys.F11, Devices.DeviceKeys.F12
}),
- _Gradient = new EffectsEngine.EffectBrush()
+ _Gradient = new EffectsEngine.LinearEffectBrush()
{
- type = EffectBrush.BrushType.Linear,
- colorGradients = new SortedDictionary {
+ ColorGradients = new SortedDictionary {
{ 0f, Color.FromArgb(255, 0, 255, 0) },
{ 0.5f, Color.OrangeRed },
{ 1f, Color.Red }
diff --git a/Project-Aurora/Project-Aurora/Profiles/Desktop/Event_Idle.cs b/Project-Aurora/Project-Aurora/Profiles/Desktop/Event_Idle.cs
index e60d56b81..52dcecddb 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Desktop/Event_Idle.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Desktop/Event_Idle.cs
@@ -127,7 +127,7 @@ public override void UpdateLights(EffectFrame frame)
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));
+ var drop_spec = new ColorBox.ColorSpectrum(Global.Configuration.idle_effect_primary_color, Color.FromArgb(0, Global.Configuration.idle_effect_primary_color));
foreach (Devices.DeviceKeys raindrop in raindrops_keys)
{
@@ -217,7 +217,7 @@ public override void UpdateLights(EffectFrame frame)
}
layer.Fill(Global.Configuration.idle_effect_secondary_color);
- ColorSpectrum drop_spec2 = new ColorSpectrum(
+ var drop_spec2 = new ColorBox.ColorSpectrum(
Global.Configuration.idle_effect_primary_color,
Color.FromArgb(0, Global.Configuration.idle_effect_primary_color));
diff --git a/Project-Aurora/Project-Aurora/Profiles/ETS2/ETS2Profile.cs b/Project-Aurora/Project-Aurora/Profiles/ETS2/ETS2Profile.cs
index b4ed1d8ee..0924c5f69 100644
--- a/Project-Aurora/Project-Aurora/Profiles/ETS2/ETS2Profile.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/ETS2/ETS2Profile.cs
@@ -60,9 +60,8 @@ public override void Reset() {
new Layer("Throttle Key", new PercentGradientLayerHandler {
Properties = new PercentGradientLayerHandlerProperties {
- _Gradient = new EffectBrush() {
- type = EffectBrush.BrushType.Linear,
- colorGradients = new SortedDictionary {
+ _Gradient = new LinearEffectBrush() {
+ ColorGradients = new SortedDictionary {
{ 0, Color.FromArgb(0, 255, 255) },
{ 1, Color.FromArgb(0, 255, 0) }
}
@@ -76,9 +75,8 @@ public override void Reset() {
new Layer("Brake Key", new PercentGradientLayerHandler {
Properties = new PercentGradientLayerHandlerProperties {
- _Gradient = new EffectBrush() {
- type = EffectBrush.BrushType.Linear,
- colorGradients = new SortedDictionary {
+ _Gradient = new LinearEffectBrush() {
+ ColorGradients = new SortedDictionary {
{ 0, Color.FromArgb(0, 255, 255) },
{ 1, Color.FromArgb(255, 0, 0) }
}
@@ -104,9 +102,8 @@ public override void Reset() {
new Layer("RPM", new PercentGradientLayerHandler {
Properties = new PercentGradientLayerHandlerProperties {
- _Gradient = new EffectBrush() {
- type = EffectBrush.BrushType.Linear,
- colorGradients = new SortedDictionary {
+ _Gradient = new LinearEffectBrush() {
+ ColorGradients = new SortedDictionary {
{ 0, Color.FromArgb(65, 255, 0) },
{ 0.65f, Color.FromArgb(67, 255, 0) },
{ 0.75f, Color.FromArgb(0, 100, 255) },
@@ -240,9 +237,8 @@ public override void Reset() {
new Layer("Fuel", new PercentGradientLayerHandler {
Properties = new PercentGradientLayerHandlerProperties {
- _Gradient = new EffectBrush() {
- type = EffectBrush.BrushType.Linear,
- colorGradients = new SortedDictionary {
+ _Gradient = new LinearEffectBrush() {
+ ColorGradients = new SortedDictionary {
{ 0f, Color.FromArgb(255, 0, 0) },
{ 0.25f, Color.FromArgb(255, 0, 0) },
{ 0.375f, Color.FromArgb(255, 255, 0) },
@@ -260,9 +256,8 @@ public override void Reset() {
new Layer("Air Pressure", new PercentGradientLayerHandler {
Properties = new PercentGradientLayerHandlerProperties {
- _Gradient = new EffectBrush() {
- type = EffectBrush.BrushType.Linear,
- colorGradients = new SortedDictionary {
+ _Gradient = new LinearEffectBrush() {
+ ColorGradients = new SortedDictionary {
{ 0f, Color.FromArgb(255, 0, 0) },
{ 0.25f, Color.FromArgb(255, 0, 0) },
{ 0.375f, Color.FromArgb(255, 255, 0) },
diff --git a/Project-Aurora/Project-Aurora/Profiles/Osu/OsuProfile.cs b/Project-Aurora/Project-Aurora/Profiles/Osu/OsuProfile.cs
index 562b1925d..03cad1507 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Osu/OsuProfile.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Osu/OsuProfile.cs
@@ -131,9 +131,8 @@ public override void Reset() {
Properties = new EqualizerLayerHandlerProperties {
_ViewType = EqualizerPresentationType.GradientColorShift,
_MaxAmplitude = 25,
- _Gradient = new EffectsEngine.EffectBrush {
- type = EffectsEngine.EffectBrush.BrushType.Linear,
- colorGradients = new SortedDictionary {
+ _Gradient = new EffectsEngine.LinearEffectBrush {
+ ColorGradients = new SortedDictionary {
{ 0, Color.Magenta },
{ 0.5f, Color.Cyan },
{ 1, Color.Magenta }
diff --git a/Project-Aurora/Project-Aurora/Profiles/Payday 2/Layers/PD2BackgroundLayerHandler.cs b/Project-Aurora/Project-Aurora/Profiles/Payday 2/Layers/PD2BackgroundLayerHandler.cs
index 2ce527132..aaf29869e 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Payday 2/Layers/PD2BackgroundLayerHandler.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Payday 2/Layers/PD2BackgroundLayerHandler.cs
@@ -198,7 +198,7 @@ public override EffectLayer Render(IGameState state)
{
double percentSuspicious = ((double)pd2.Players.LocalPlayer.SuspicionAmount / (double)1.0);
- ColorSpectrum suspicion_spec = new ColorSpectrum(Properties.LowSuspicionColor, Properties.HighSuspicionColor);
+ var suspicion_spec = new ColorBox.ColorSpectrum(Properties.LowSuspicionColor, Properties.HighSuspicionColor);
suspicion_spec.SetColorAt(0.5f, Properties.MediumSuspicionColor);
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)));
@@ -211,7 +211,7 @@ public override EffectLayer Render(IGameState state)
}
else if (pd2.Level.Phase == LevelPhase.Point_of_no_return && pd2.Game.State == GameStates.Ingame)
{
- ColorSpectrum no_return_spec = new ColorSpectrum(Color.Red, Color.Yellow);
+ var no_return_spec = new ColorBox.ColorSpectrum(Color.Red, Color.Yellow);
if (pd2.Level.NoReturnTime != no_return_timeleft)
{
no_return_timeleft = pd2.Level.NoReturnTime;
diff --git a/Project-Aurora/Project-Aurora/Profiles/RocketLeague/RocketLeagueProfile.cs b/Project-Aurora/Project-Aurora/Profiles/RocketLeague/RocketLeagueProfile.cs
index a0fc81959..9ba09d7cd 100644
--- a/Project-Aurora/Project-Aurora/Profiles/RocketLeague/RocketLeagueProfile.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/RocketLeague/RocketLeagueProfile.cs
@@ -28,7 +28,7 @@ public override void Reset()
{
_PercentType = PercentEffectType.AllAtOnce,
_Sequence = new KeySequence(new Devices.DeviceKeys[] { Devices.DeviceKeys.Peripheral, Devices.DeviceKeys.Peripheral_Logo } ),
- _Gradient = new EffectsEngine.EffectBrush(new ColorSpectrum(Color.Yellow, Color.Red).SetColorAt(0.75f, Color.OrangeRed)),
+ _Gradient = new EffectsEngine.LinearEffectBrush(new ColorBox.ColorSpectrum(Color.Yellow, Color.Red).SetColorAt(0.75f, Color.OrangeRed)),
_BlinkThreshold = 0.0,
_BlinkDirection = false,
_VariablePath = "Player/Boost",
@@ -45,7 +45,7 @@ public override void Reset()
Devices.DeviceKeys.F6, Devices.DeviceKeys.F7, Devices.DeviceKeys.F8, Devices.DeviceKeys.F9, Devices.DeviceKeys.F10,
Devices.DeviceKeys.F11, Devices.DeviceKeys.F12
}),
- _Gradient = new EffectsEngine.EffectBrush(new ColorSpectrum(Color.Yellow, Color.Red).SetColorAt(0.75f, Color.OrangeRed)),
+ _Gradient = new EffectsEngine.LinearEffectBrush(new ColorBox.ColorSpectrum(Color.Yellow, Color.Red).SetColorAt(0.75f, Color.OrangeRed)),
_BlinkThreshold = 0.0,
_BlinkDirection = false,
_VariablePath = "Player/Boost",
diff --git a/Project-Aurora/Project-Aurora/Profiles/Subnautica/SubnauticaProfile.cs b/Project-Aurora/Project-Aurora/Profiles/Subnautica/SubnauticaProfile.cs
index 001832f69..f27170189 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Subnautica/SubnauticaProfile.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Subnautica/SubnauticaProfile.cs
@@ -118,11 +118,8 @@ public override void Reset() {
new Layer("Background", new PercentGradientLayerHandler() {
Properties = new PercentGradientLayerHandlerProperties {
- _Gradient = new EffectBrush() {
- type = EffectBrush.BrushType.Linear,
- start = new PointF(0, 0),
- end = new PointF(1, 0),
- colorGradients = new SortedDictionary {
+ _Gradient = new LinearEffectBrush() {
+ ColorGradients = new SortedDictionary {
{ 0, Color.FromArgb(46, 176, 255) },
{ 1, Color.FromArgb(0, 3, 53) }
}
diff --git a/Project-Aurora/Project-Aurora/Profiles/TModLoader/TModLoaderProfile.cs b/Project-Aurora/Project-Aurora/Profiles/TModLoader/TModLoaderProfile.cs
index 3f1103df9..25830a962 100644
--- a/Project-Aurora/Project-Aurora/Profiles/TModLoader/TModLoaderProfile.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/TModLoader/TModLoaderProfile.cs
@@ -45,11 +45,8 @@ public override void Reset() {
}),
new Layer("Background", new PercentGradientLayerHandler() {
Properties = new PercentGradientLayerHandlerProperties {
- _Gradient = new EffectBrush() {
- type = EffectBrush.BrushType.Linear,
- start = new PointF(0, 0),
- end = new PointF(1, 0),
- colorGradients = new SortedDictionary {
+ _Gradient = new LinearEffectBrush() {
+ ColorGradients = new SortedDictionary {
{ 0, Color.White },
{ 1, Color.DarkGray }
}
@@ -79,12 +76,9 @@ public override void Reset() {
private static EffectBrush GetColorGradient(Color start, Color end)
{
- return new EffectBrush()
+ return new LinearEffectBrush()
{
- type = EffectBrush.BrushType.Linear,
- start = new PointF(0, 0),
- end = new PointF(1, 0),
- colorGradients = new SortedDictionary {
+ ColorGradients = new SortedDictionary {
{ 0, start },
{ 1, end }
}
diff --git a/Project-Aurora/Project-Aurora/Project-Aurora.csproj b/Project-Aurora/Project-Aurora/Project-Aurora.csproj
index e0b45ea4a..ddcfa4995 100644
--- a/Project-Aurora/Project-Aurora/Project-Aurora.csproj
+++ b/Project-Aurora/Project-Aurora/Project-Aurora.csproj
@@ -367,7 +367,6 @@
-
Control_ATS.xaml
@@ -1373,7 +1372,6 @@
-
diff --git a/Project-Aurora/Project-Aurora/Settings/LayerEffectConfig.cs b/Project-Aurora/Project-Aurora/Settings/LayerEffectConfig.cs
index b85205f31..57327d2a4 100644
--- a/Project-Aurora/Project-Aurora/Settings/LayerEffectConfig.cs
+++ b/Project-Aurora/Project-Aurora/Settings/LayerEffectConfig.cs
@@ -5,17 +5,6 @@
namespace Aurora.Settings
{
- public enum AnimationType
- {
- [Description("No Animation")]
- None,
- [Description("Translate X and Y")]
- Translate_XY,
- [Description("(Radial only) Zoom in")]
- Zoom_in,
- [Description("(Radial only) Zoom out")]
- Zoom_out,
- };
public class LayerEffectConfig
{
@@ -24,7 +13,6 @@ public class LayerEffectConfig
public float speed;
public float angle;
public float gradient_size = 100.0f;
- public AnimationType animation_type;
public bool animation_reverse;
public EffectBrush brush;
@@ -34,10 +22,9 @@ public class LayerEffectConfig
// profiles. >:( Little bit frustrating and verbose. Perhaps we can replace this next time there is a breaking change...
[JsonIgnore] public Color Primary { get => primary; set => primary = value; }
[JsonIgnore] public Color Secondary { get => secondary; set => secondary = value; }
- [JsonIgnore] public float Speed { get => speed; set => speed = value; }
+ [JsonIgnore] public float AnimationSpeed { get => speed; set => speed = value; }
[JsonIgnore] public float Angle { get => angle; set => angle = value; }
[JsonIgnore] public float GradientSize { get => gradient_size; set => gradient_size = value; }
- [JsonIgnore] public AnimationType AnimationType { get => animation_type; set => animation_type = value; }
[JsonIgnore] public bool AnimationReverse { get => animation_reverse; set => animation_reverse = value; }
[JsonIgnore] public EffectBrush Brush { get => brush; set => brush = value; }
@@ -61,23 +48,8 @@ public LayerEffectConfig(Color primary_color, Color secondary_color)
secondary = secondary_color;
speed = 1.0f;
angle = 0.0f;
- animation_type = AnimationType.Translate_XY;
animation_reverse = false;
- brush = new EffectBrush(
- new System.Drawing.Drawing2D.LinearGradientBrush(
- new PointF(0, 0),
- new PointF(1, 0),
- primary,
- secondary
- )
- {
- InterpolationColors = new System.Drawing.Drawing2D.ColorBlend(2)
- {
- Colors = new Color[] { primary, secondary },
- Positions = new float[] { 0.0f, 1.0f }
- }
- }
- );
+ brush = new LinearEffectBrush(new ColorBox.ColorSpectrum(primary_color, secondary_color));
}
public LayerEffectConfig(LayerEffectConfig otherConfig)
@@ -86,7 +58,6 @@ public LayerEffectConfig(LayerEffectConfig otherConfig)
secondary = otherConfig.secondary;
speed = otherConfig.speed;
angle = otherConfig.angle;
- animation_type = otherConfig.animation_type;
animation_reverse = otherConfig.animation_reverse;
brush = otherConfig.brush;
}
diff --git a/Project-Aurora/Project-Aurora/Settings/Layers/Control_EqualizerLayer.xaml.cs b/Project-Aurora/Project-Aurora/Settings/Layers/Control_EqualizerLayer.xaml.cs
index 321475832..e665b5dbf 100644
--- a/Project-Aurora/Project-Aurora/Settings/Layers/Control_EqualizerLayer.xaml.cs
+++ b/Project-Aurora/Project-Aurora/Settings/Layers/Control_EqualizerLayer.xaml.cs
@@ -52,16 +52,7 @@ public void SetSettings()
this.eq_background_mode.SelectedItem = (this.DataContext as EqualizerLayerHandler).Properties._BackgroundMode;
this.Clr_primary_color.SelectedColor = Utils.ColorUtils.DrawingColorToMediaColor((this.DataContext as EqualizerLayerHandler).Properties._PrimaryColor ?? System.Drawing.Color.Empty);
this.Clr_secondary_color.SelectedColor = Utils.ColorUtils.DrawingColorToMediaColor((this.DataContext as EqualizerLayerHandler).Properties._SecondaryColor ?? System.Drawing.Color.Empty);
-
- Brush brush = (this.DataContext as EqualizerLayerHandler).Properties._Gradient.GetMediaBrush();
- try
- {
- this.gradient_editor.Brush = brush;
- }
- catch (Exception exc)
- {
- Global.logger.Error("Could not set brush, exception: " + exc);
- }
+ this.gradient_editor.Brush = (this.DataContext as EqualizerLayerHandler).Properties._Gradient;
this.updown_max_amplitude_value.Value = (int)(this.DataContext as EqualizerLayerHandler).Properties._MaxAmplitude;
this.Clr_dim_color.SelectedColor = Utils.ColorUtils.DrawingColorToMediaColor((this.DataContext as EqualizerLayerHandler).Properties._DimColor ?? System.Drawing.Color.Empty);
@@ -105,37 +96,21 @@ private void Clr_secondary_color_SelectedColorChanged(object sender, RoutedPrope
private void Gradient_editor_BrushChanged(object sender, ColorBox.BrushChangedEventArgs e)
{
if (IsLoaded && settingsset && this.DataContext is EqualizerLayerHandler && sender is ColorBox.ColorBox)
- (this.DataContext as EqualizerLayerHandler).Properties._Gradient = new EffectsEngine.EffectBrush((sender as ColorBox.ColorBox).Brush);
+ (this.DataContext as EqualizerLayerHandler).Properties._Gradient = (sender as ColorBox.ColorBox).Brush;
}
private void Button_SetGradientRainbow_Click(object sender, RoutedEventArgs e)
{
- (this.DataContext as EqualizerLayerHandler).Properties._Gradient = new EffectBrush(ColorSpectrum.Rainbow);
+ (this.DataContext as EqualizerLayerHandler).Properties._Gradient = new LinearEffectBrush(ColorBox.ColorSpectrum.Rainbow);
- Brush brush = (this.DataContext as EqualizerLayerHandler).Properties._Gradient.GetMediaBrush();
- try
- {
- this.gradient_editor.Brush = brush;
- }
- catch (Exception exc)
- {
- Global.logger.Error("Could not set brush, exception: " + exc);
- }
+ this.gradient_editor.Brush = (this.DataContext as EqualizerLayerHandler).Properties._Gradient;
}
private void Button_SetGradientRainbowLoop_Click(object sender, RoutedEventArgs e)
{
- (this.DataContext as EqualizerLayerHandler).Properties._Gradient = new EffectBrush(ColorSpectrum.RainbowLoop);
+ (this.DataContext as EqualizerLayerHandler).Properties._Gradient = new LinearEffectBrush(ColorBox.ColorSpectrum.RainbowLoop);
- Brush brush = (this.DataContext as EqualizerLayerHandler).Properties._Gradient.GetMediaBrush();
- try
- {
- this.gradient_editor.Brush = brush;
- }
- catch (Exception exc)
- {
- Global.logger.Error("Could not set brush, exception: " + exc);
- }
+ this.gradient_editor.Brush = (this.DataContext as EqualizerLayerHandler).Properties._Gradient;
}
private void updown_max_amplitude_value_ValueChanged(object sender, RoutedPropertyChangedEventArgs