コード例 #1
0
        public EffectSettingsWindow(LayerEffectConfig EffectConfig)
        {
            InitializeComponent();

            this.EffectConfig = EffectConfig;
            this.primary_color.SelectedColor         = Utils.ColorUtils.DrawingColorToMediaColor(EffectConfig.primary);
            this.secondary_color.SelectedColor       = Utils.ColorUtils.DrawingColorToMediaColor(EffectConfig.secondary);
            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.LogLine("Could not set brush, exception: " + exc, Logging_Level.Error);

                //this.gradient_editor.Brush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0, 0));
            }

            this.gradient_editor.BrushChanged += Gradient_editor_BrushChanged;
        }
コード例 #2
0
        public EffectSettingsWindow()
        {
            InitializeComponent();

            EffectConfig = new LayerEffectConfig();
            this.primary_color.SelectedColor   = Utils.ColorUtils.DrawingColorToMediaColor(EffectConfig.primary);
            this.secondary_color.SelectedColor = Utils.ColorUtils.DrawingColorToMediaColor(EffectConfig.secondary);
            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.BrushChanged += Gradient_editor_BrushChanged;
        }
コード例 #3
0
 public Control_GradientEditor(LayerEffectConfig gradient)
 {
     InitializeComponent();
     animTypeCb.ItemsSource = Utils.EnumUtils.GetEnumItemsSource <AnimationType>();
     DataContext            = gradient;
 }
コード例 #4
0
ファイル: EffectLayer.cs プロジェクト: twigglius/Aurora
        /// <summary>
        /// Creates a new instance of the EffectLayer class with a specified layer name. And applies a LayerEffect onto this EffectLayer instance.
        /// Using the parameters from LayerEffectConfig and a specified region in RectangleF
        /// </summary>
        /// <param name="name">A layer name</param>
        /// <param name="effect">An enum specifying which LayerEffect to apply</param>
        /// <param name="effect_config">Configurations for the LayerEffect</param>
        /// <param name="rect">A rectangle specifying what region to apply effects in</param>
        public EffectLayer(string name, LayerEffects effect, LayerEffectConfig effect_config, RectangleF rect = new RectangleF())
        {
            this.name  = name;
            colormap   = new Bitmap(Effects.canvas_width, Effects.canvas_height);
            peripheral = new Color();
            Brush brush;
            float shift = 0.0f;

            switch (effect)
            {
            case LayerEffects.ColorOverlay:
                Fill(effect_config.primary);
                break;

            case LayerEffects.ColorBreathing:
                Fill(effect_config.primary);
                float sine = (float)Math.Pow(Math.Sin((double)((Utils.Time.GetMillisecondsSinceEpoch() % 10000L) / 10000.0f) * 2 * Math.PI * effect_config.speed), 2);
                Fill(Color.FromArgb((byte)(sine * 255), effect_config.secondary));
                break;

            case LayerEffects.RainbowShift_Horizontal:
                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;
                }

                if (effect_config.animation_reverse)
                {
                    shift *= -1.0f;
                }

                brush = CreateRainbowBrush();
                (brush as LinearGradientBrush).RotateTransform(0.0f);
                (brush as LinearGradientBrush).TranslateTransform(shift, shift);

                Fill(brush);

                effect_config.last_effect_call = Utils.Time.GetMillisecondsSinceEpoch();
                break;

            case LayerEffects.RainbowShift_Vertical:
                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;
                }

                if (effect_config.animation_reverse)
                {
                    shift *= -1.0f;
                }

                brush = CreateRainbowBrush();
                (brush as LinearGradientBrush).RotateTransform(90.0f);
                (brush as LinearGradientBrush).TranslateTransform(shift, shift);

                Fill(brush);

                effect_config.last_effect_call = Utils.Time.GetMillisecondsSinceEpoch();
                break;

            case LayerEffects.RainbowShift_Diagonal:
                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;
                }

                if (effect_config.animation_reverse)
                {
                    shift *= -1.0f;
                }

                brush = CreateRainbowBrush();
                (brush as LinearGradientBrush).RotateTransform(45.0f);
                (brush as LinearGradientBrush).TranslateTransform(shift, shift);

                Fill(brush);

                effect_config.last_effect_call = Utils.Time.GetMillisecondsSinceEpoch();
                break;

            case LayerEffects.RainbowShift_Diagonal_Other:
                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;
                }

                if (effect_config.animation_reverse)
                {
                    shift *= -1.0f;
                }

                brush = CreateRainbowBrush();
                (brush as LinearGradientBrush).RotateTransform(-45.0f);
                (brush as LinearGradientBrush).TranslateTransform(shift, shift);

                Fill(brush);

                effect_config.last_effect_call = Utils.Time.GetMillisecondsSinceEpoch();
                break;

            case LayerEffects.RainbowShift_Custom_Angle:
                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;
                }

                if (effect_config.animation_reverse)
                {
                    shift *= -1.0f;
                }

                brush = CreateRainbowBrush();
                (brush as LinearGradientBrush).RotateTransform(effect_config.angle);
                (brush as LinearGradientBrush).TranslateTransform(shift, shift);

                Fill(brush);

                effect_config.last_effect_call = Utils.Time.GetMillisecondsSinceEpoch();
                break;

            case LayerEffects.GradientShift_Custom_Angle:
                effect_config.shift_amount += ((Utils.Time.GetMillisecondsSinceEpoch() - effect_config.last_effect_call) / 1000.0f) * 0.25f * 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;
                }

                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, rect.Height);
                    }
                    else
                    {
                        (brush as LinearGradientBrush).ScaleTransform(Effects.canvas_height, Effects.canvas_height);
                    }

                    (brush as LinearGradientBrush).TranslateTransform(shift, shift);
                    (brush as LinearGradientBrush).RotateTransform(effect_config.angle);
                }
                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;


                        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), rect.Height - (2.0f * y_offset));
                        }
                        else
                        {
                            (brush as PathGradientBrush).ScaleTransform(Effects.canvas_height + x_offset, Effects.canvas_height + y_offset);
                        }
                    }
                    else
                    {
                        if (!rect.IsEmpty)
                        {
                            (brush as PathGradientBrush).TranslateTransform(rect.X, rect.Y);
                            (brush as PathGradientBrush).ScaleTransform(rect.Width, rect.Height);
                        }
                        else
                        {
                            (brush as PathGradientBrush).ScaleTransform(Effects.canvas_height, Effects.canvas_height);
                        }
                    }

                    (brush as PathGradientBrush).RotateTransform(effect_config.angle);

                    //(brush as PathGradientBrush).TranslateTransform(x_shift, y_shift);
                }

                Fill(brush);

                effect_config.last_effect_call = Utils.Time.GetMillisecondsSinceEpoch();
                break;

            default:
                break;
            }
        }