
- #HOW TO USE ANIMATION COMPOSER 2 HOW TO#
- #HOW TO USE ANIMATION COMPOSER 2 UPDATE#
- #HOW TO USE ANIMATION COMPOSER 2 WINDOWS 10#
- #HOW TO USE ANIMATION COMPOSER 2 WINDOWS#
#HOW TO USE ANIMATION COMPOSER 2 WINDOWS#
This is a very rich collection of Win2D based helper classes and controls for Windows Composition. When looking for more advanced extension methods for CanvasPathBuilder, I came across the CompositionProToolkit by Ratish Philip. Getting some help from CompositionProToolkit The old clock successfully upgraded from straight rectangles to rounded ones, ellipses, and lines. The –smooth- animations to redraw the hour, minute, and seconds hands act at CompositionObject level –the base class of all visual composition objects-, so there was no need to modify from the original clock here. _secondhandSpriteShape = _compositor.CreateSpriteShape(pathGeometry) Var pathGeometry = _compositor.CreatePathGeometry() Var compositionPath = new CompositionPath(canvasGeometry) Var canvasGeometry = CanvasGeometry.CreatePath(canvasPathBuilder) Var canvasPathBuilder = new CanvasPathBuilder(new CanvasDevice()) ĬanvasPathBuilder.BuildPathWithLines(new(float x, float y) Fortunately I came across this blog post by Daren May where he shares an extension method on CanvasPathBuilder to build a path with lines: The constructor of CompositionPath requires a IGeometrySource2D instance, which brings you pretty close to the Win2D primitives (and out of my enterprise XAML developer comfort zone). Drawing it was a little bit harder than expected. The seconds hand is a triangle made out of three lines. HandShapeVisual.Size = new Vector2(200.0f, 200.0f) HandShapeVisual = _compositor.CreateShapeVisual() _hourhandSpriteShape.CenterPoint = new Vector2(3.0f, 60.0f) _hourhandSpriteShape.Offset = new Vector2(97.0f, 40.0f) _hourhandSpriteShape.FillBrush = _compositor.CreateColorBrush(Colors.DarkSlateGray) _hourhandSpriteShape = _compositor.CreateSpriteShape(roundedRectangle) RoundedRectangle.CornerRadius = new Vector2(3.0f, 3.0f) RoundedRectangle.Size = new Vector2(6.0f, 63.0f) Var roundedRectangle = _compositor.CreateRoundedRectangleGeometry()

To demonstrate these new classes I built a Clock UserControl that’s made of ellipses and rounded rectangles drawn and animated by Windows Composition.

#HOW TO USE ANIMATION COMPOSER 2 HOW TO#
In this article I will not dive too much in detail on how to draw and animate Composition sprites in XAML. for drawing controls or for animating content à la Lottie.

This is good news for developers who want to use more of Windows Composition in their apps, e.g.
#HOW TO USE ANIMATION COMPOSER 2 UPDATE#
The latest update does more than rectangles: it supports shapes from lines and ellipses to rounded rectangles and even SVG paths.
#HOW TO USE ANIMATION COMPOSER 2 WINDOWS 10#
Before the April Windows 10 Update, this API was limited to drawing rectangles that you could fill with a brush or an image. This article explains how you can use the Composition API to display and animate geometric shapes in a UWP app.
