/// <summary> /// Retrieves a Vector4 value of the property defined in /// the CompositionPropertySet using the given key /// </summary> /// <param name="propertySet">CompositionPropertySet</param> /// <param name="key">Key of the object to retrieve</param> /// <returns>Vector4</returns> public static Vector4 GetVector4(this CompositionPropertySet propertySet, string key) { return(propertySet.Get <Vector4>(key)); }
/// <summary> /// Retrieves a Boolean value of the property defined in /// the CompositionPropertySet using the given key /// </summary> /// <param name="propertySet">CompositionPropertySet</param> /// <param name="key">Key of the object to retrieve</param> /// <returns>Boolean</returns> public static bool GetBoolean(this CompositionPropertySet propertySet, string key) { return(propertySet.Get <bool>(key)); }
/// <summary> /// Retrieves a Scalar value of the property defined in /// the CompositionPropertySet using the given key /// </summary> /// <param name="propertySet">CompositionPropertySet</param> /// <param name="key">Key of the object to retrieve</param> /// <returns>Scalar</returns> public static float GetScalar(this CompositionPropertySet propertySet, string key) { return(propertySet.Get <float>(key)); }
/// <summary> /// Retrieves a Quaternion value of the property defined in /// the CompositionPropertySet using the given key /// </summary> /// <param name="propertySet">CompositionPropertySet</param> /// <param name="key">Key of the object to retrieve</param> /// <returns>Quaternion</returns> public static Quaternion GetQuaternion(this CompositionPropertySet propertySet, string key) { return(propertySet.Get <Quaternion>(key)); }
/// <summary> /// Retrieves a Matrix4x4 value of the property defined in /// the CompositionPropertySet using the given key /// </summary> /// <param name="propertySet">CompositionPropertySet</param> /// <param name="key">Key of the object to retrieve</param> /// <returns>Matrix4x4</returns> public static Matrix4x4 GetMatrix4x4(this CompositionPropertySet propertySet, string key) { return(propertySet.Get <Matrix4x4>(key)); }
/// <summary> /// Retrieves a Color value of the property defined in /// the CompositionPropertySet using the given key /// </summary> /// <param name="propertySet">CompositionPropertySet</param> /// <param name="key">Key of the object to retrieve</param> /// <returns>Color</returns> public static Color GetColor(this CompositionPropertySet propertySet, string key) { return(propertySet.Get <Color>(key)); }
private async void OnPageLoaded(object sender, RoutedEventArgs e) { _compositor = Window.Current.Compositor; _generator = _compositor.CreateCompositionGenerator(); var gridSize = new Vector2((float)RootGrid.ActualWidth, (float)RootGrid.ActualHeight); var anim = _compositor.CreatePathKeyFrameAnimation(); _rootVisual = _compositor.CreateSpriteVisual(); _rootVisual.Size = gridSize; // Create the surface brush from the image var imageSurface = await _generator.CreateImageSurfaceAsync( new Uri("ms-appx:///Assets/Images/Cat.png"), new Size(400, 400), ImageSurfaceOptions.Default); var imageBrush = _compositor.CreateSurfaceBrush(imageSurface); // Create the clipped visuals for (var i = 0; i < 145; i++) { var visual = _compositor.CreateSpriteVisual(); visual.Offset = new Vector3(400, 400, 0); visual.Size = new Vector2(400, 400); visual.Brush = imageBrush; visual.AnchorPoint = new Vector2(0.5f); var radius = 290 - (i * 2); // Create the GeometricClip for this visual var clipGeometry = CanvasGeometry.CreateCircle(null, new Vector2(200, 200), radius); visual.Clip = _compositor.CreateGeometricClip(clipGeometry); _rootVisual.Children.InsertAtTop(visual); _visuals.Add(visual); } // Display the rootVisual ElementCompositionPreview.SetElementChildVisual(RootGrid, _rootVisual); // Reverse the visuals list so that the items in the list are now sorted // in z-order from top to bottom _visuals.Reverse(); // The topmost visual would track the pointer position _dragVisual = _visuals.First(); // Get the CompositionPropertySet which tracks the pointer position on the RootGrid _pointerTrackerSet = ElementCompositionPreview.GetPointerPositionPropertySet(RootGrid); // Animate the topmost visual so that it tracks and follows the pointer position _pointerTrackerAnimation = _compositor.GenerateVector3KeyFrameAnimation() .HavingDuration(PointerTrackerAnimationDuration) .RepeatsForever(); _pointerTrackerAnimation.InsertExpressionKeyFrame(0f, c => new VisualTarget().Offset); _pointerTrackerAnimation.InsertExpressionKeyFrame( 1f, c => c.Lerp(new VisualTarget().Offset, _pointerTrackerSet.Get <Vector3>("Position"), DefaultLerpAmount), _compositor.CreateEaseOutQuinticEasingFunction()); // Animate the remaining visuals in such a way that each visual tracks and follows the // position of the visual above it. var prevChild = _dragVisual; foreach (var child in _visuals.Skip(1)) { var offsetAnimation = _compositor.GenerateVector3KeyFrameAnimation() .HavingDuration(ChildOffsetAnimationDuration) .RepeatsForever(); offsetAnimation.InsertExpressionKeyFrame(0f, c => new VisualTarget().Offset); offsetAnimation.InsertExpressionKeyFrame( 1f, c => c.Lerp(new VisualTarget().Offset, prevChild.Offset, DefaultLerpAmount), _compositor.CreateEaseOutQuinticEasingFunction()); child.StartAnimation(() => child.Offset, offsetAnimation); prevChild = child; } }