Esempio n. 1
0
        private static void GetActiveEffects(IGraphicsEffectSource effectSource, List <Type> typesSeen)
        {
            // Record this node if it is an IGraphicsEffect.
            IGraphicsEffect effect = effectSource as IGraphicsEffect;

            if (effect != null)
            {
                typesSeen.Add(effect.GetType());

                foreach (var property in effect.GetType().GetRuntimeProperties())
                {
                    if (property.PropertyType == typeof(IGraphicsEffectSource))
                    {
                        // Recurse into any source properties that could themselves be effects.
                        var source = (IGraphicsEffectSource)property.GetValue(effect);

                        GetActiveEffects(source, typesSeen);
                    }
                    else if (property.PropertyType == typeof(IList <IGraphicsEffectSource>))
                    {
                        // Recurse into any array source properties.
                        var sources = (IList <IGraphicsEffectSource>)property.GetValue(effect);

                        foreach (var source in sources)
                        {
                            GetActiveEffects(source, typesSeen);
                        }
                    }
                }
            }
        }
        public override void DrawEffect(IGraphicsEffectSource eff, CanvasDrawingSession session)
        {
            var gb = new GaussianBlurEffect()
            {
                Source     = eff,
                BlurAmount = PenAttribute.BlurAmount
            };

            session.DrawImage(gb, Bounds, Bounds);
        }
Esempio n. 3
0
        public void ConfigureDissolve(float dissolveFactor, IGraphicsEffectSource source)
        {
            dissolveFactor = 0.5f * ((float)Math.Tanh((4f * dissolveFactor) - 2f) + 1);
            if (dissolveFactor > 1f)
            {
                dissolveFactor = 1f;
            }


            _dissolveEffect.Properties["dissolveAmount"] = 1 - dissolveFactor;
            _dissolveEffect.Source1 = source;
        }
Esempio n. 4
0
        public static ICanvasImage CreateContrastEffect(IGraphicsEffectSource loadedImage, Slider valueSlider)
        {
            valueSlider.Minimum       = -1;
            valueSlider.Maximum       = 1;
            valueSlider.StepFrequency = 0.1;

            var brightnessEffect = new ContrastEffect
            {
                Source   = loadedImage,
                Contrast = 0
            };

            return(brightnessEffect);
        }
Esempio n. 5
0
        public static ICanvasImage CreateExposureEffect(IGraphicsEffectSource loadedImage, Slider valueSlider)
        {
            valueSlider.Minimum       = -2;
            valueSlider.Maximum       = 2;
            valueSlider.StepFrequency = 0.2;


            var brightnessEffect = new ExposureEffect
            {
                Source   = loadedImage,
                Exposure = 0
            };

            return(brightnessEffect);
        }
Esempio n. 6
0
 Transform2DEffect CreateShadowEffect(IGraphicsEffectSource source, ShadowParam param)
 {
     return(new Transform2DEffect
     {
         Source = new Transform2DEffect
         {
             Source = new ShadowEffect
             {
                 BlurAmount = param.Blur,
                 ShadowColor = Color.FromArgb(param.Alpha, 0, 0, 0),
                 Source = source
             },
         },
     });
 }
Esempio n. 7
0
        public static async Task <IGraphicsEffect> ConcatenateEffectWithTintAndBorderAsync(
            [NotNull] Compositor compositor,
            [NotNull] IGraphicsEffectSource source, [NotNull] IDictionary <String, CompositionBrush> parameters,
            Color color, float colorMix,
            [CanBeNull] CanvasControl canvas, [NotNull] Uri uri, int timeThreshold = 1000, bool reload = false)
        {
            // Setup the tint effect
            ArithmeticCompositeEffect tint = new ArithmeticCompositeEffect
            {
                MultiplyAmount = 0,
                Source1Amount  = 1 - colorMix,
                Source2Amount  = colorMix, // Mix the background with the desired tint color
                Source1        = source,
                Source2        = new ColorSourceEffect {
                    Color = color
                }
            };

            // Get the noise brush using Win2D
            CompositionSurfaceBrush noiseBitmap = canvas == null
                ? await LoadWin2DSurfaceBrushFromImageAsync(compositor, uri, reload)
                : await LoadWin2DSurfaceBrushFromImageAsync(compositor, canvas, uri, timeThreshold, reload);

            // Make sure the Win2D brush was loaded correctly
            if (noiseBitmap != null)
            {
                // Layer 4 - Noise effect
                BorderEffect borderEffect = new BorderEffect
                {
                    ExtendX = CanvasEdgeBehavior.Wrap,
                    ExtendY = CanvasEdgeBehavior.Wrap,
                    Source  = new CompositionEffectSourceParameter(nameof(noiseBitmap))
                };
                BlendEffect blendEffect = new BlendEffect
                {
                    Background = tint,
                    Foreground = borderEffect,
                    Mode       = BlendEffectMode.Overlay
                };
                parameters.Add(nameof(noiseBitmap), noiseBitmap);
                return(blendEffect);
            }
            return(tint);
        }
Esempio n. 8
0
        private static void GetActiveEffects(IGraphicsEffectSource effectSource, List<Type> typesSeen)
        {
            // Record this node if it is an IGraphicsEffect.
            IGraphicsEffect effect = effectSource as IGraphicsEffect;

            if (effect != null)
            {
                typesSeen.Add(effect.GetType());

                foreach (var property in effect.GetType().GetRuntimeProperties())
                {
                    if (property.PropertyType == typeof(IGraphicsEffectSource))
                    {
                        // Recurse into any source properties that could themselves be effects.
                        var source = (IGraphicsEffectSource)property.GetValue(effect);

                        GetActiveEffects(source, typesSeen);
                    }
                    else if (property.PropertyType == typeof(IList<IGraphicsEffectSource>))
                    {
                        // Recurse into any array source properties.
                        var sources = (IList<IGraphicsEffectSource>)property.GetValue(effect);

                        foreach (var source in sources)
                        {
                            GetActiveEffects(source, typesSeen);
                        }
                    }
                }
            }
        }
 public static PipelineBuilder FromEffect(IGraphicsEffectSource effect)
 {
     return(new PipelineBuilder(() => new ValueTask <IGraphicsEffectSource>(effect)));
 }
Esempio n. 10
0
 public abstract void DrawEffect(IGraphicsEffectSource eff, CanvasDrawingSession session);
Esempio n. 11
0
 public GaussianBlurEffect(IGraphicsEffectSource source) : base(source)
 {
 }
Esempio n. 12
0
 public ICanvasEffect GenerateEffect(IGraphicsEffectSource source)
 {
     return(new TableTransferEffect {
         AlphaDisable = true, RedTable = redTable, GreenTable = greenTable, BlueTable = blueTable, Source = source
     });
 }
Esempio n. 13
0
 /// <summary>
 /// Creates a new wrapper instance with the given parameters
 /// </summary>
 /// <param name="pipeline">The current effects pipeline</param>
 /// <param name="brush">The host backdrop brush instance</param>
 public HostBackdropInstanceWrapper(IGraphicsEffectSource pipeline, CompositionBackdropBrush brush)
 {
     Pipeline = pipeline;
     Brush    = brush;
 }
Esempio n. 14
0
 public ICanvasEffect GenerateEffect(IGraphicsEffectSource source)
 {
     return(new TableTransfer3DEffect {
         Table = table, Source = source
     });
 }
Esempio n. 15
0
 public SaturationEffect(IGraphicsEffectSource source) : base(source)
 {
 }
Esempio n. 16
0
 Transform2DEffect CreateShadowEffect(IGraphicsEffectSource source, ShadowParam param)
 {
     return new Transform2DEffect
     {
         Source = new Transform2DEffect
         {
             Source = new ShadowEffect
             {
                 BlurAmount = param.Blur,
                 ShadowColor = Color.FromArgb(param.Alpha, 0, 0, 0),
                 Source = source
             },
         },
     };
 }