标签: windows-composition-api

如何在Windows 10 Creators Update中使用Acrylic Accent?

我找不到任何使用Acrylic Accent(CreateBackdropBrush)的详细文档.我在StackOverflow中发现了一个有用的帖子但它没有帮助入门.所以请为这篇文章创建一个详细的答案,以便每个人都可以学习.

更新:

微软发布了官方的丙烯酸材料文件

注意:

如果有人不知道丙烯酸口音.Acrylic Accent是Windows 10 Creators Update中的新功能,允许应用程序背景模糊和透明.在此输入图像描述在此输入图像描述

c# win-universal-app uwp windows-composition-api fluent-design

29
推荐指数
3
解决办法
2万
查看次数

UWP成分Api是否支持颜色替换?

我一直在尝试寻找与颜色替换相关的示例,这里是一个使用Photoshop的例子,例如,可以采用蓝色阴影并用红色阴影替换它:

之前: 在此输入图像描述

后: 在此输入图像描述

这是否可以使用最新版本的Composition Api中的Composition Effects?

我见过与Hue Rotations,Temperature和Tint有关的例子:

https://xamlbrewer.wordpress.com/2016/04/08/uwp-composition-effects-hue-rotation/

https://xamlbrewer.wordpress.com/2016/04/19/uwp-composition-effects-temperature-and-tint/

但我想知道api是否能够使用Effects来切换图像中的颜色范围?

c# uwp xaml-composition windows-composition-api

11
推荐指数
1
解决办法
466
查看次数

彩色动画轻松

我一直在关注这个问题来制作彩色动画.

我可以创建动画,它运行正常,直到动画再次开始.有一刻,感觉动画已在那里开始/停止片刻.我希望动画能够平滑地运行,以便它不会在颜色中显示任何重新启动的效果.有可能吗?

我使用以下代码:

        <Storyboard x:Key="GradientAnimation"
                RepeatBehavior="Forever"
                Storyboard.TargetName="BackgroundBrush"
                SpeedRatio="0.3">
        <ColorAnimationUsingKeyFrames
            Storyboard.TargetProperty="(UIElement.Background).(LinearGradientBrush.GradientStops)[0].(GradientStop.Color)"
            EnableDependentAnimation="True"
            BeginTime="-0:0:0.5">

            <LinearColorKeyFrame KeyTime="0:0:0" Value="Black"/>
            <LinearColorKeyFrame KeyTime="0:0:1" Value="Red"/>
            <LinearColorKeyFrame KeyTime="0:0:2" Value="Black"/>
            <LinearColorKeyFrame KeyTime="0:0:3" Value="Red"/>
            <LinearColorKeyFrame KeyTime="0:0:4" Value="Black"/>
            <LinearColorKeyFrame KeyTime="0:0:5" Value="Red"/>
            <LinearColorKeyFrame KeyTime="0:0:6" Value="Black"/>
            <LinearColorKeyFrame KeyTime="0:0:7" Value="Red"/>

        </ColorAnimationUsingKeyFrames>
        <ColorAnimationUsingKeyFrames
            Storyboard.TargetProperty="(UIElement.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)"
            EnableDependentAnimation="True">

            <LinearColorKeyFrame KeyTime="0:0:0" Value="Red"/>
            <LinearColorKeyFrame KeyTime="0:0:1" Value="Black"/>
            <LinearColorKeyFrame KeyTime="0:0:2" Value="Red"/>
            <LinearColorKeyFrame KeyTime="0:0:3" Value="Black"/>
            <LinearColorKeyFrame KeyTime="0:0:4" Value="Red"/>
            <LinearColorKeyFrame KeyTime="0:0:5" Value="Black"/>
            <LinearColorKeyFrame KeyTime="0:0:6" Value="Red"/>
            <LinearColorKeyFrame KeyTime="0:0:7" Value="Black"/>

        </ColorAnimationUsingKeyFrames>
    </Storyboard>
Run Code Online (Sandbox Code Playgroud)

我在代码隐藏中开始这个动画:

((Storyboard)Resources["GradientAnimation"]).Begin();
Run Code Online (Sandbox Code Playgroud)

也许有某种"缓和"方法混合了动画的开始和停止,因此它看起来像长时间运行的动画一样流畅.有什么建议?

c# uwp uwp-xaml windows-composition-api

3
推荐指数
1
解决办法
834
查看次数

如何在UWP Composition API中组合多个效果

我想结合模糊,饱和度和色调.

我有一个混合效果,由GaussianBlur和Tint颜色组成.

_compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;

var graphicsEffect = new BlendEffect
{
    Mode = BlendEffectMode.Overlay,
    Background = new GaussianBlurEffect()
    {
        Name = "Blur",
        Source = new CompositionEffectSourceParameter("Backdrop"),
        BlurAmount = 10f
        BorderMode = EffectBorderMode.Hard,
    },
    Foreground = new ColorSourceEffect()
    {
        Name = "Tint",
        Color = Color.FromArgb(120, 255, 255, 255),
    }
};


var effectFactory = _compositor.CreateEffectFactory(graphicsEffect)
_brush = effectFactory.CreateBrush();
_brush.SetSourceParameter("Backdrop", _compositor.CreateBackdropBrush());

_effectSprite = _compositor.CreateSpriteVisual();
_effectSprite.Size = new Vector2((float)this.ActualWidth, (float)this.ActualHeight)
_effectSprite.Brush = _brush;
ElementCompositionPreview.SetElementChildVisual(this, _effectSprite)
Run Code Online (Sandbox Code Playgroud)

如何在此效果之前或之后添加SaturationEffect?

我试图将它包装到另一个BlendEffect中并将另一个BackdropBrush设置为SaturationEffect的源,但我只有白色背景.

我也尝试从SaturationEffect创建画笔并将其设置为GaussianBlur的源代码,但我得到异常"Invalid Source Brush"

c# uwp windows-composition-api

2
推荐指数
1
解决办法
333
查看次数