public override void Draw(Graphics g, float scale = 1.0f)
        {
            RectangleF _scaledDimension = new RectangleF(_dimension.X * scale, _dimension.Y * scale, _dimension.Width * scale, _dimension.Height * scale);

            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);

            SortedDictionary <float, System.Drawing.Color> newColorGradients = new SortedDictionary <float, System.Drawing.Color>();
            ColorSpectrum spectrum = _newbrush.GetColorSpectrum();
            var           colors   = _newbrush.colorGradients;

            float _cutOffPoint = _width / _radius;

            if (_cutOffPoint < 1.0f)
            {
                _cutOffPoint = 1.0f - _cutOffPoint;

                foreach (var kvp in spectrum.GetSpectrumColors())
                {
                    newColorGradients.Add((1 - _cutOffPoint) * kvp.Key + _cutOffPoint, kvp.Value);
                }

                newColorGradients.Add(_cutOffPoint - 0.0001f, Color.Transparent);
                newColorGradients.Add(0.0f, Color.Transparent);

                _newbrush.colorGradients = newColorGradients;
            }
            else if (_cutOffPoint > 1.0f)
            {
                foreach (var kvp in spectrum.GetSpectrumColors())
                {
                    if (kvp.Key >= (1 - 1 / _cutOffPoint))
                    {
                        newColorGradients.Add((1 - 1 / _cutOffPoint) * kvp.Key + _cutOffPoint, kvp.Value);
                    }
                }

                newColorGradients.Add(0.0f, spectrum.GetColorAt((1 - 1 / _cutOffPoint)));
            }

            _newbrush.SetBrushType(EffectBrush.BrushType.Radial);
            Brush brush = _newbrush.GetDrawingBrush();

            if (brush is PathGradientBrush)
            {
                (brush as PathGradientBrush).TranslateTransform(_scaledDimension.X, _scaledDimension.Y);
                (brush as PathGradientBrush).ScaleTransform(_scaledDimension.Width - (2.0f), _scaledDimension.Height - (2.0f));

                Matrix rotationMatrix = new Matrix();
                rotationMatrix.RotateAt(-_angle, new PointF(_center.X * scale, _center.Y * scale), MatrixOrder.Append);

                Matrix originalMatrix = g.Transform;
                g.Transform = rotationMatrix;
                g.FillEllipse(brush, _scaledDimension);
                g.Transform = originalMatrix;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Applies the effect.
        /// </summary>
        /// <returns>
        /// An array of strings of the effect properties to change.
        /// </returns>
        public override string[] ApplyEffect()
        {
            var gaussianBlur = new GaussianBlurEffect
            {
                Name         = EffectName,
                BlurAmount   = 0f,
                Optimization = EffectOptimization.Balanced,
                BorderMode   = EffectBorderMode.Hard,
                Source       = new CompositionEffectSourceParameter("source")
            };

            //BlendEffect finalEffect = new BlendEffect
            //{
            //    Foreground = new CompositionEffectSourceParameter("NoiseImage"),
            //    Background = gaussianBlur,
            //    Mode = BlendEffectMode.Screen,
            //};

            var propertyToChange    = $"{EffectName}.BlurAmount";
            var propertiesToAnimate = new[] { propertyToChange };

            EffectBrush = Compositor.CreateEffectFactory(gaussianBlur, propertiesToAnimate).CreateBrush();
            //EffectBrush.SetSourceParameter("NoiseImage", m_noiseBrush);
            EffectBrush.SetSourceParameter("source", Compositor.CreateHostBackdropBrush());

            return(propertiesToAnimate);
        }
 /// <inheritdoc />
 public override Task AnimateAsync(FixedAnimationType animationType, TimeSpan duration)
 {
     // Apply all the animations in parallel and wait for their completion
     return(Task.WhenAll(
                from pair in PropertiesAnimationValues
                let target = animationType == FixedAnimationType.In ? pair.Value.On : pair.Value.Off
                             select EffectBrush.StartAnimationAsync(pair.Key, target, duration)));
 }
 public LayerEffectConfig(LayerEffectConfig otherConfig)
 {
     primary           = otherConfig.primary;
     secondary         = otherConfig.secondary;
     speed             = otherConfig.speed;
     angle             = otherConfig.angle;
     animation_type    = otherConfig.animation_type;
     animation_reverse = otherConfig.animation_reverse;
     brush             = otherConfig.brush;
 }
Beispiel #5
0
 public override void Default()
 {
     base.Default();
     _PrimaryColor         = Utils.ColorUtils.GenerateRandomColor();
     _SecondaryColor       = Utils.ColorUtils.GenerateRandomColor();
     _Gradient             = new EffectBrush(ColorSpectrum.RainbowLoop).SetBrushType(EffectBrush.BrushType.Linear);
     _EQType               = EqualizerType.PowerBars;
     _ViewType             = EqualizerPresentationType.SolidColor;
     _MaxAmplitude         = 20.0f;
     _DimBackgroundOnSound = false;
     _DimColor             = Color.FromArgb(169, 0, 0, 0);
     _Frequencies          = new SortedSet <float>()
     {
         60, 170, 310, 600, 1000, 2000, 3000, 4000, 5000
     };
 }
        /// <summary>
        /// Applies the effect.
        /// </summary>
        /// <returns>
        /// An array of strings of the effect properties to change.
        /// </returns>
        public override string[] ApplyEffect()
        {
            var brightnessEffect = new BrightnessEffect
            {
                Name   = EffectName,
                Source = new CompositionEffectSourceParameter("source")
            };

            var propertyToChange    = $"{EffectName}.WhitePoint";
            var propertiesToAnimate = new[] { propertyToChange };

            EffectBrush = Compositor.CreateEffectFactory(brightnessEffect, propertiesToAnimate).CreateBrush();
            EffectBrush.SetSourceParameter("source", Compositor.CreateBackdropBrush());

            return(propertiesToAnimate);
        }
        private Brush GetBrush(float value, float position, float max_position)
        {
            if (Properties.ViewType == EqualizerPresentationType.AlternatingColor)
            {
                if (value >= 0)
                {
                    return(new SolidBrush(Properties.PrimaryColor));
                }
                else
                {
                    return(new SolidBrush(Properties.SecondaryColor));
                }
            }
            else if (Properties.ViewType == EqualizerPresentationType.GradientNotched)
            {
                return(new SolidBrush(Properties.Gradient.GetColorSpectrum().GetColorAt(position, max_position)));
            }
            else if (Properties.ViewType == EqualizerPresentationType.GradientHorizontal)
            {
                EffectBrush e_brush = new EffectBrush(Properties.Gradient.GetColorSpectrum())
                {
                    start = PointF.Empty,
                    end   = new PointF(sourceRect.Width, 0)
                };

                return(e_brush.GetDrawingBrush());
            }
            else if (Properties.ViewType == EqualizerPresentationType.GradientColorShift)
            {
                return(new SolidBrush(Properties.Gradient.GetColorSpectrum().GetColorAt(Utils.Time.GetMilliSeconds(), 1000)));
            }
            else if (Properties.ViewType == EqualizerPresentationType.GradientVertical)
            {
                EffectBrush e_brush = new EffectBrush(Properties.Gradient.GetColorSpectrum())
                {
                    start = new PointF(0, sourceRect.Height),
                    end   = PointF.Empty
                };

                return(e_brush.GetDrawingBrush());
            }
            else
            {
                return(new SolidBrush(Properties.PrimaryColor));
            }
        }
Beispiel #8
0
        /// <summary>
        /// Applies the effect.
        /// </summary>
        /// <returns>
        /// An array of strings of the effect properties to change.
        /// </returns>
        public override string[] ApplyEffect()
        {
            var saturationEffect = new SaturationEffect
            {
                Saturation = 1f,
                Name       = EffectName,
                Source     = new CompositionEffectSourceParameter("source")
            };

            var propertyToChange    = $"{EffectName}.Saturation";
            var propertiesToAnimate = new[] { propertyToChange };

            EffectBrush = Compositor.CreateEffectFactory(saturationEffect, propertiesToAnimate).CreateBrush();
            EffectBrush.SetSourceParameter("source", Compositor.CreateBackdropBrush());

            return(propertiesToAnimate);
        }
 public override void Default()
 {
     base.Default();
     _Sequence              = new KeySequence(Effects.WholeCanvasFreeForm);
     _PrimaryColor          = Utils.ColorUtils.GenerateRandomColor();
     _SecondaryColor        = Utils.ColorUtils.GenerateRandomColor();
     _Gradient              = new EffectBrush(ColorSpectrum.RainbowLoop).SetBrushType(EffectBrush.BrushType.Linear);
     _EQType                = EqualizerType.PowerBars;
     _ViewType              = EqualizerPresentationType.SolidColor;
     _MaxAmplitude          = 20.0f;
     _ScaleWithSystemVolume = false;
     _BackgroundMode        = EqualizerBackgroundMode.Disabled;
     _DimColor              = Color.FromArgb(169, 0, 0, 0);
     _Frequencies           = new SortedSet <float>()
     {
         50, 95, 130, 180, 250, 350, 500, 620, 700, 850, 1200, 1600, 2200, 3000, 4100, 5600, 7700, 10000
     };
 }
Beispiel #10
0
 public LayerEffectConfig()
 {
     primary               = Color.Red;
     secondary             = Color.Blue;
     speed                 = 1.0f;
     angle                 = 0.0f;
     animation_type        = AnimationType.Translate_XY;
     animation_reverse     = false;
     respect_cz_dimensions = true;
     brush                 = new EffectBrush(
         new System.Drawing.Drawing2D.LinearGradientBrush(
             new PointF(0, 0),
             new PointF(1, 0),
             primary,
             secondary
             )
         );
 }
Beispiel #11
0
        private Brush GetBrush(float value, float position, float max_position)
        {
            var rect = Properties.Sequence.GetAffectedRegion();

            if (Properties.ViewType == EqualizerPresentationType.AlternatingColor)
            {
                if (value >= 0)
                {
                    return(new SolidBrush(Properties.PrimaryColor));
                }
                else
                {
                    return(new SolidBrush(Properties.SecondaryColor));
                }
            }
            else if (Properties.ViewType == EqualizerPresentationType.GradientNotched)
            {
                return(new SolidBrush(Properties.Gradient.GetColorSpectrum().GetColorAt(position, max_position)));
            }
            else if (Properties.ViewType == EqualizerPresentationType.GradientHorizontal)
            {
                EffectBrush e_brush = new EffectBrush(Properties.Gradient.GetColorSpectrum());
                e_brush.start = new PointF(rect.X, 0);
                e_brush.end   = new PointF(rect.Width + rect.X, 0);

                return(e_brush.GetDrawingBrush());
            }
            else if (Properties.ViewType == EqualizerPresentationType.GradientColorShift)
            {
                return(new SolidBrush(Properties.Gradient.GetColorSpectrum().GetColorAt(Utils.Time.GetMilliSeconds(), 1000)));
            }
            else if (Properties.ViewType == EqualizerPresentationType.GradientVertical)
            {
                EffectBrush e_brush = new EffectBrush(Properties.Gradient.GetColorSpectrum());
                e_brush.start = new PointF(0, rect.Height + rect.Y);
                e_brush.end   = new PointF(0, rect.Y);

                return(e_brush.GetDrawingBrush());
            }
            else
            {
                return(new SolidBrush(Properties.PrimaryColor));
            }
        }
        /// <summary>
        /// Applies the effect.
        /// </summary>
        /// <returns>
        /// An array of strings of the effect properties to change.
        /// </returns>
        public override string[] ApplyEffect()
        {
            var gaussianBlur = new GaussianBlurEffect
            {
                Name         = EffectName,
                BlurAmount   = 0f,
                Optimization = EffectOptimization.Balanced,
                BorderMode   = EffectBorderMode.Hard,
                Source       = new CompositionEffectSourceParameter("source")
            };

            var propertyToChange    = $"{EffectName}.BlurAmount";
            var propertiesToAnimate = new[] { propertyToChange };

            EffectBrush = Compositor.CreateEffectFactory(gaussianBlur, propertiesToAnimate).CreateBrush();
            EffectBrush.SetSourceParameter("source", Compositor.CreateBackdropBrush());

            return(propertiesToAnimate);
        }
Beispiel #13
0
        public override void Draw(Graphics g, float scale = 1.0f)
        {
            RectangleF _scaledDimension = new RectangleF(_dimension.X * scale, _dimension.Y * scale, _dimension.Width * scale, _dimension.Height * scale);

            PointF rotatePoint = new PointF(_scaledDimension.X + (_scaledDimension.Width / 2.0f), _scaledDimension.Y + (_scaledDimension.Height / 2.0f));

            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);

            Matrix rotationMatrix = new Matrix();

            rotationMatrix.RotateAt(-_angle, rotatePoint, MatrixOrder.Append);

            Matrix originalMatrix = g.Transform;

            g.Transform = rotationMatrix;
            g.FillRectangle(_newbrush.GetDrawingBrush(), _scaledDimension);
            g.Transform = originalMatrix;
        }
Beispiel #14
0
 public LayerEffectConfig(Color primary_color, Color secondary_color)
 {
     primary           = primary_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 }
         }
     }
         );
 }
Beispiel #15
0
 public AnimationFilledGradientRectangle(RectangleF dimension, EffectBrush brush, float duration = 0.0f) : base(dimension, Color.Transparent, duration)
 {
     _gradientBrush = brush;
 }
 public AnimationGradientCircle(float x, float y, float radius, EffectBrush brush, int width = 1, float duration = 0.0f) : base(x, y, radius, Color.Transparent, width, duration)
 {
     _gradientBrush = brush;
 }
 public AnimationGradientCircle(RectangleF dimension, EffectBrush brush, int width = 1, float duration = 0.0f) : base(dimension, Color.Transparent, width, duration)
 {
     _gradientBrush = brush;
 }
Beispiel #18
0
 public AnimationFilledGradientRectangle(float x, float y, float rect_width, float rect_height, EffectBrush brush, float duration = 0.0f) : base(x, y, rect_width, rect_height, Color.Transparent, duration)
 {
     _gradientBrush = brush;
 }
 /// <inheritdoc />
 public override Task AnimateAsync(FixedAnimationType animationType, TimeSpan duration)
 {
     return(EffectBrush.StartAnimationAsync(Parameters.Property,
                                            animationType == FixedAnimationType.In ? Parameters.On : Parameters.Off, duration));
 }