Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/Animations/src/Expressions/ExpressionFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1283,8 +1283,8 @@ public ExpressionNodeInfo(OperationType nodeOperationKind, string operationStrin
{ ExpressionNodeType.ColorHsl, new ExpressionNodeInfo(OperationType.Function, "colorhsl") },
{ ExpressionNodeType.ColorRgb, new ExpressionNodeInfo(OperationType.Function, "colorrgb") },
{ ExpressionNodeType.ColorLerp, new ExpressionNodeInfo(OperationType.Function, "colorlerp") },
{ ExpressionNodeType.ColorLerpHsl, new ExpressionNodeInfo(OperationType.Function, "colorhsllerp") },
{ ExpressionNodeType.ColorLerpRgb, new ExpressionNodeInfo(OperationType.Function, "colorrgblerp") },
{ ExpressionNodeType.ColorLerpHsl, new ExpressionNodeInfo(OperationType.Function, "colorlerphsl") },
{ ExpressionNodeType.ColorLerpRgb, new ExpressionNodeInfo(OperationType.Function, "colorlerprgb") },
{ ExpressionNodeType.Concatenate, new ExpressionNodeInfo(OperationType.Function, "concatenate") },
{ ExpressionNodeType.Distance, new ExpressionNodeInfo(OperationType.Function, "distance") },
{ ExpressionNodeType.DistanceSquared, new ExpressionNodeInfo(OperationType.Function, "distancesquared") },
Expand Down
1 change: 1 addition & 0 deletions components/Animations/tests/Animations.Tests.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Test_AnimationBuilderStart.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Test_ExpressionFunctions.cs" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion components/Animations/tests/Test_AnimationBuilderStart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace AnimationsExperiment.Tests;

[TestClass]
[TestCategory("Test_AnimationBuilderStart")]
[TestCategory(nameof(Test_AnimationBuilderStart))]
public class Test_AnimationBuilderStart : VisualUITestBase
{
[TestMethod]
Expand Down
59 changes: 59 additions & 0 deletions components/Animations/tests/Test_ExpressionFunctions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if WINUI2
using Windows.UI.Composition;
using Windows.UI.Xaml.Hosting;
#elif WINUI3
using Microsoft.UI.Composition;
using Microsoft.UI.Xaml.Hosting;
#endif

using System.Numerics;
using CommunityToolkit.Tests;
using CommunityToolkit.Tooling.TestGen;
using CommunityToolkit.WinUI.Animations.Expressions;

namespace AnimationsExperiment.Tests;

[TestClass]
[TestCategory(nameof(Test_ExpressionFunctions))]
public partial class Test_ExpressionFunctions : VisualUITestBase
{
[UIThreadTestMethod]
public void ColorLerpRgb(Grid rootGrid)
{
// See https://github.com/CommunityToolkit/Windows/issues/303
var compositor = ElementCompositionPreview.GetElementVisual(rootGrid).Compositor;
var brush = compositor.CreateColorBrush();
var temp = ExpressionFunctions.ColorRgb(255f, 255f, 0f, 0f);
var color = ExpressionFunctions.ColorLerpRgb(temp, temp, 0.5f);

brush.StartAnimation("Color", color);

var visual = compositor.CreateSpriteVisual();
visual.Brush = brush;
visual.RelativeSizeAdjustment = Vector2.One;

ElementCompositionPreview.SetElementChildVisual(rootGrid, visual);
}

[UIThreadTestMethod]
public void ColorLerpHsl(Grid rootGrid)
{
// See https://github.com/CommunityToolkit/Windows/issues/303
var compositor = ElementCompositionPreview.GetElementVisual(rootGrid).Compositor;
var brush = compositor.CreateColorBrush();
var temp = ExpressionFunctions.ColorHsl(255f, 255f, 0f);
var color = ExpressionFunctions.ColorLerpHsl(temp, temp, 0.5f);

brush.StartAnimation("Color", color);

var visual = compositor.CreateSpriteVisual();
visual.Brush = brush;
visual.RelativeSizeAdjustment = Vector2.One;

ElementCompositionPreview.SetElementChildVisual(rootGrid, visual);
}
}