All Projects → Sergio0694 → UICompositionAnimations

Sergio0694 / UICompositionAnimations

Licence: GPL-3.0 license
A powerful and easy to use library to work with Composition and XAML animations and Win2D effects

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to UICompositionAnimations

Nightingale Rest Api Client
A modern, resource-efficient REST API client for Windows. (Issues-only repo)
Stars: ✭ 290 (+233.33%)
Mutual labels:  xaml, uwp, windows10
Ambie
A simple, elegant white noise app for Xbox and Windows
Stars: ✭ 187 (+114.94%)
Mutual labels:  xaml, uwp, windows10
Uwp App Launcher Mobile
[Open Source] It's like the iOS and Android Home Screens but for Windows 10 (Phones).
Stars: ✭ 47 (-45.98%)
Mutual labels:  xaml, uwp, windows10
UWP-Package-Installer
An UWP installer for appx/appxbundle packages
Stars: ✭ 85 (-2.3%)
Mutual labels:  xaml, uwp, uwp-applications
Q42.winrt
Useful library for data driven Windows Phone 8 and Windows 8 C# / XAML WinRT projects
Stars: ✭ 111 (+27.59%)
Mutual labels:  xaml, uwp, windows10
Xamarin Demos
This repository contains the Syncfusion Xamarin UI control’s samples and the guide to use them.
Stars: ✭ 218 (+150.57%)
Mutual labels:  xaml, uwp
Quarrel
A UWP discord client
Stars: ✭ 238 (+173.56%)
Mutual labels:  xaml, uwp
react-native-xaml
A React Native Windows library to use XAML / WinUI controls
Stars: ✭ 55 (-36.78%)
Mutual labels:  xaml, uwp
XamlIslands
Repository with several XAML Islands v1 samples (Win32, WPF, and WinForms) to demonstrate how to use it.
Stars: ✭ 47 (-45.98%)
Mutual labels:  xaml, uwp
Codehub
A UWP GitHub Client
Stars: ✭ 162 (+86.21%)
Mutual labels:  xaml, uwp
LRReader
A feature-complete reader and client for LANraragi
Stars: ✭ 62 (-28.74%)
Mutual labels:  xaml, uwp
LocalNotifications
Create and manage in-app notifications in Universal Windows applications.
Stars: ✭ 37 (-57.47%)
Mutual labels:  xaml, uwp
Directx12gameengine
DirectX 12 .NET game engine
Stars: ✭ 194 (+122.99%)
Mutual labels:  xaml, uwp
Quick-Pad
Quick Pad is a modern notepad app featuring fluent design
Stars: ✭ 183 (+110.34%)
Mutual labels:  xaml, uwp
Windowstemplatestudio
Windows Template Studio quickly builds a UWP app, using a wizard-based UI to turn your needs into a foundation of Windows 10 patterns and best practices.
Stars: ✭ 2,089 (+2301.15%)
Mutual labels:  xaml, uwp
IconPacks.Browser
The Browser for all available Icon packages from MahApps.Metro.IconPacks
Stars: ✭ 74 (-14.94%)
Mutual labels:  xaml, uwp
Win32Acrylic
Acrylic demo applications based on different technology stack
Stars: ✭ 35 (-59.77%)
Mutual labels:  xaml, uwp
Rise-Media-Player
One media player for everything you own or stream; whether it's music or videos, online or offline Rise Media Player does it all. And it's beautiful and native with the latest version of WinUI.
Stars: ✭ 600 (+589.66%)
Mutual labels:  xaml, uwp
WordpadUWP
A UWP version of... WordPad!
Stars: ✭ 54 (-37.93%)
Mutual labels:  xaml, uwp
Mvvmvalidation
Lightweight library that helps reduce boilerplate when implementing validation in XAML MVVM applications
Stars: ✭ 141 (+62.07%)
Mutual labels:  xaml, uwp

UICompositionAnimations

The UICompositionAnimations library exposes classes and APIs to quickly implement animations and effects to a UWP application. It also has a collection of helper methods to load Win2D images, dispatch code to the UI thread and more.

Get it from NuGet

NuGet NuGet

UICompositionAnimations is now part of the Windows Community Toolkit!

All the shared APIs are now removed and available directly from the toolkit, visit the repo here! 🚀

Used by

OneLocker myTube! Brainf*ck#
OneLocker screens IDE IDE

Table of Contents

Installing from NuGet

To install UICompositionAnimations, run the following command in the Package Manager Console

Install-Package UICompositionAnimations

More details available here.

Quick start

Animations

The available animation APIs use the fluent pattern and support combining multiple animations togetger. The main entry point is the UIElementExtensions.Animation method, that returns an IAnimationBuilder object targeting the input UIElement. This object exposes all the available animation APIs.

You can use it like this:

MyControl.Animation()
         .Opacity(0)
         .Translation(Axis.X, 60)
         .Duration(250)
         .Start();

It is also possible to set an initial delay, and to wait for the animation to be completed. Also, should you need to do so in a particular situation, it is also possible to choose between the Windows.UI.Composition and Windows.UI.Xaml.Media.Animation APIs to run the animations. To toggle between the two, just pass a FrameworkLayer value to the Animation method. Furthermore, each animation API has two overloads: one that just takes the target value, and one that also sets the initial value for the animation. It is also possible to specify an easing function for each individual animation. Here is another, more complex example:

await MyControl.Animation(FrameworkLayer.Xaml)
               .Opacity(0, 1, Easing.CircleEaseOut)
               .Scale(1.2, 1, Easing.QuadraticEaseInOut)
               .Duration(500)
               .Delay(250)
               .StartAsync();

UI.Composition effects

The library provides several ways to use UI.Composition effects: there are both ready to use XAML brushes (like a customizable acrylic brush), a CompositionBrushBuilder class to create complex composition effect pipelines, and more.

Declare an acrylic brush in XAML

xmlns:brushes="using:UICompositionAnimations.Brushes">
  
<!--The acrylic brush to use in the app-->
<brushes:AcrylicBrush
    x:Key="InAppGrayAcrylicBrush"
    Source="HostBackdrop"
    BlurAmount="8"
    Tint="#FF222222"
    TintMix="0.6"
    TextureUri="/Assets/Misc/noise.png"/>

Note: the NoiseTextureUri parameter must be set to a .png image with a noise texture. It is up to the developer to create his own noise texture and to import it into the app. An easy plugin to create one is NoiseChoice for Paint.NET.

Create custom effects in XAML:

Using the APIs in UICompositionAnimations.Brushes.Effects it is also possible to build complex Composition/Win2D pipelines directly from XAML, in a declarative way. This is how to define a custom host backdrop acrylic brush:

xmlns:brushes="using:UICompositionAnimations.Brushes"
xmlns:effects="using:UICompositionAnimations.Brushes.Effects"

<brushes:PipelineBrush>
    <brushes:PipelineBrush.Effects>
        <effects:BackdropEffect Source="HostBackdrop"/>
        <effects:LuminanceEffect/>
        <effects:OpacityEffect Value="0.4"/>
        <effects:BlendEffect Mode="Multiply">
            <effects:BlendEffect.Input>
                <effects:BackdropEffect Source="HostBackdrop"/>
            </effects:BlendEffect.Input>
        </effects:BlendEffect>
        <effects:TintEffect Color="#FF1E90FF" Opacity="0.2"/>
        <effects:BlendEffect Mode="Overlay" Placement="Background">
            <effects:BlendEffect.Input>
                <effects:TileEffect Uri="/Assets/noise_high.png"/>
            </effects:BlendEffect.Input>
        </effects:BlendEffect>
    </brushes:PipelineBrush.Effects>
</brushes:PipelineBrush>

Create and assign an acrylic brush in C#

control.Background = PipelineBuilder.FromHostBackdropAcrylic(Colors.DarkOrange, 0.6f, new Uri("ms-appx:///Assets/noise.png"))
                                    .AsBrush();

Build an acrylic effect pipeline from scratch:

Brush brush = PipelineBuilder.FromHostBackdropBrush()
                             .Effect(source => new LuminanceToAlphaEffect { Source = source })
                             .Opacity(0.4f)
                             .Blend(PipelineBuilder.FromHostBackdropBrush(), BlendEffectMode.Multiply)
                             .Tint(Color.FromArgb(0xFF, 0x14, 0x14, 0x14), 0.8f)
                             .Blend(PipelineBuilder.FromTiles("/Assets/noise.png".ToAppxUri()), BlendEffectMode.Overlay, Placement.Background)
                             .AsBrush();

The PipelineBuilder class can also be used to quickly implement custom XAML brushes with an arbitrary effects pipeline. To do so, just inherit from XamlCompositionEffectBrushBase and setup your own effects pipeline in the OnBrushRequested method.

Get a custom effect that can be animated:

// Build the effects pipeline
XamlCompositionBrush acrylic = PipelineBuilder.FromHostBackdropAcrylic(Colors.Orange, 0.6f, new Uri("ms-appx:///Assets/noise.png"))
                                              .Saturation(1, out EffectAnimation animation)
                                              .AsBrush();
acrylic.Bind(animation, out XamlEffectAnimation saturation); // Bind the effect animation to the target brush

// Later on, when needed
saturation(0.2f, 250); // Animate the opacity to 0.2 in 250ms

Misc

Many utility methods are also available, here are some useful classes:

  • DispatcherHelper: exposes methods to easily execute code on the UI thread or on a target CoreDispatcher object
  • Win2DImageHelper: exposes APIs to quickly load a Win2D image on a CompositionSurfaceBrush object
  • PointerHelper: exposes APIs to quickly setup pointer event handlers for UIElements
  • AsyncMutex: an async mutex included into System.Threading.Tasks that can be used to asynchronously acquire a lock with a using block.

Requirements

At least Windows 10 April Update (17134.x)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].