From 869ba6986e0b26830b553521b0ec03b3e9a71d67 Mon Sep 17 00:00:00 2001 From: h82258652 <842053625@qq.com> Date: Tue, 19 Dec 2023 17:38:20 +0800 Subject: [PATCH 1/2] init commit --- components/Animations/src/Expressions/ExpressionFunctions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/Animations/src/Expressions/ExpressionFunctions.cs b/components/Animations/src/Expressions/ExpressionFunctions.cs index fb940af1..b0b48182 100644 --- a/components/Animations/src/Expressions/ExpressionFunctions.cs +++ b/components/Animations/src/Expressions/ExpressionFunctions.cs @@ -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") }, From 05adb744bc57244579d6008b10082ee266b74bf5 Mon Sep 17 00:00:00 2001 From: Arlo Godfrey Date: Tue, 9 Jan 2024 13:31:04 -0600 Subject: [PATCH 2/2] Added unit tests for ExpressionFunctions.ColorLerpRgb and ColorLerpHsl --- .../tests/Animations.Tests.projitems | 1 + .../tests/Test_AnimationBuilderStart.cs | 2 +- .../tests/Test_ExpressionFunctions.cs | 59 +++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 components/Animations/tests/Test_ExpressionFunctions.cs diff --git a/components/Animations/tests/Animations.Tests.projitems b/components/Animations/tests/Animations.Tests.projitems index 32acc124..1fb5e1f4 100644 --- a/components/Animations/tests/Animations.Tests.projitems +++ b/components/Animations/tests/Animations.Tests.projitems @@ -10,5 +10,6 @@ + \ No newline at end of file diff --git a/components/Animations/tests/Test_AnimationBuilderStart.cs b/components/Animations/tests/Test_AnimationBuilderStart.cs index a25dfa6e..7cea9d73 100644 --- a/components/Animations/tests/Test_AnimationBuilderStart.cs +++ b/components/Animations/tests/Test_AnimationBuilderStart.cs @@ -9,7 +9,7 @@ namespace AnimationsExperiment.Tests; [TestClass] -[TestCategory("Test_AnimationBuilderStart")] +[TestCategory(nameof(Test_AnimationBuilderStart))] public class Test_AnimationBuilderStart : VisualUITestBase { [TestMethod] diff --git a/components/Animations/tests/Test_ExpressionFunctions.cs b/components/Animations/tests/Test_ExpressionFunctions.cs new file mode 100644 index 00000000..d2856b34 --- /dev/null +++ b/components/Animations/tests/Test_ExpressionFunctions.cs @@ -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); + } +}