I'm trying to apply a pointer animation using the Composition Api along with the Expression Builder. I've found a sample of what I need, but the code is imcomplete and I cannot figure out how to get the values for the variables center and distanceToCenter. The original docs and sample are here:
https://learn.microsoft.com/en-us/windows/uwp/composition/pointer-input-animations
Sample code (slightly modified):
using Microsoft.Toolkit.Uwp.UI.Animations.Expressions;
using EF = Microsoft.Toolkit.Uwp.UI.Animations.Expressions.ExpressionFunctions;
_tiltVisual = ElementCompositionPreview.GetElementVisual(element);
_pointerPositionPropSet = ElementCompositionPreview.GetPointerPositionPropertySet(element);
// || DEFINE THE EXPRESSION FOR THE ROTATION ANGLE ||
var hoverPosition = _pointerPositionPropSet.GetSpecializedReference<PointerPositionPropertySetReferenceNode>().Position;
var angleExpressionNode = EF.Conditional(hoverPosition == new Vector3(0, 0, 0),
ExpressionValues.CurrentValue.CreateScalarCurrentValue(),
35 * ((EF.Clamp(EF.Distance(center, hoverPosition), 0, distanceToCenter) % distanceToCenter) / distanceToCenter));
_tiltVisual.StartAnimation("RotationAngleInDegrees", angleExpressionNode);
// || DEFINE THE EXPRESSION FOR THE ROTATION AXIS ||
var axisAngleExpressionNode = EF.Vector3(-(hoverPosition.Y - center.Y) * EF.Conditional(hoverPosition.Y == center.Y, 0, 1),
(hoverPosition.X - center.X) * EF.Conditional(hoverPosition.X == center.X, 0, 1),
0);
_tiltVisual.StartAnimation("RotationAxis", axisAngleExpressionNode);
Thanks to Xavier Xie, I found the full code: