initial commit
commit
fbdeea55fb
|
@ -0,0 +1,224 @@
|
|||
# The following command works for downloading when using Git for Windows:
|
||||
# curl -LOf http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore
|
||||
#
|
||||
# Download this file using PowerShell v3 under Windows with the following comand:
|
||||
# Invoke-WebRequest https://gist.githubusercontent.com/kmorcinek/2710267/raw/ -OutFile .gitignore
|
||||
#
|
||||
# or wget:
|
||||
# wget --no-check-certificate http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore
|
||||
|
||||
.vscode
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.sln.docstates
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Rr]elease/
|
||||
x64/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
# build folder is nowadays used for build scripts and should not be ignored
|
||||
#build/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/packages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/packages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/packages/repositories.config
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.log
|
||||
*.scc
|
||||
|
||||
# OS generated files #
|
||||
.DS_Store*
|
||||
Icon?
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# NCrunch
|
||||
*.ncrunch*
|
||||
.*crunch*.local.xml
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.Publish.xml
|
||||
|
||||
# Windows Azure Build Output
|
||||
csx
|
||||
*.build.csdef
|
||||
|
||||
# Windows Store app package directory
|
||||
AppPackages/
|
||||
|
||||
# Others
|
||||
*.Cache
|
||||
ClientBin/
|
||||
[Ss]tyle[Cc]op.*
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.[Pp]ublish.xml
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
modulesbin/
|
||||
tempbin/
|
||||
|
||||
# EPiServer Site file (VPP)
|
||||
AppData/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file to a newer
|
||||
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# vim
|
||||
*.txt~
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# Temp files when opening LibreOffice on ubuntu
|
||||
.~lock.*
|
||||
|
||||
# svn
|
||||
.svn
|
||||
|
||||
# CVS - Source Control
|
||||
**/CVS/
|
||||
|
||||
# Remainings from resolving conflicts in Source Control
|
||||
*.orig
|
||||
|
||||
# SQL Server files
|
||||
**/App_Data/*.mdf
|
||||
**/App_Data/*.ldf
|
||||
**/App_Data/*.sdf
|
||||
|
||||
|
||||
#LightSwitch generated files
|
||||
GeneratedArtifacts/
|
||||
_Pvt_Extensions/
|
||||
ModelManifest.xml
|
||||
|
||||
# =========================
|
||||
# Windows detritus
|
||||
# =========================
|
||||
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Mac desktop service store files
|
||||
.DS_Store
|
||||
|
||||
# SASS Compiler cache
|
||||
.sass-cache
|
||||
|
||||
# Visual Studio 2014 CTP
|
||||
**/*.sln.ide
|
||||
|
||||
# Visual Studio temp something
|
||||
.vs/
|
||||
|
||||
# dotnet stuff
|
||||
project.lock.json
|
||||
|
||||
# VS 2015+
|
||||
*.vc.vc.opendb
|
||||
*.vc.db
|
||||
|
||||
# Rider
|
||||
.idea/
|
||||
|
||||
# Output folder used by Webpack or other FE stuff
|
||||
**/node_modules/*
|
||||
**/wwwroot/*
|
||||
|
||||
# SpecFlow specific
|
||||
*.feature.cs
|
||||
*.feature.xlsx.*
|
||||
*.Specs_*.html
|
||||
|
||||
#####
|
||||
# End of core ignore list, below put you custom 'per project' settings (patterns or path)
|
||||
#####
|
|
@ -0,0 +1,61 @@
|
|||
using System;
|
||||
|
||||
namespace MoonTools.Core.Easing
|
||||
{
|
||||
public static class Easing
|
||||
{
|
||||
private static void CheckTime(float time, float duration)
|
||||
{
|
||||
if (time > duration) { throw new ArgumentException($"{time} is invalid. Must be less than {duration}."); }
|
||||
}
|
||||
|
||||
private static float NormalizedTime(Func<float, float, float, float, float> easingFunction, float t) => easingFunction(t, 0, 1, 1);
|
||||
private static float TimeRange(Func<float, float> easingFunction, float time, float start, float end) => start + (end - start) * easingFunction((time - start) / (end - start));
|
||||
|
||||
public static float Linear(float t) => NormalizedTime(Linear, t);
|
||||
public static float Linear(float time, float start, float end) => TimeRange(Linear, time, start, end);
|
||||
|
||||
public static float Linear(float t, float b, float c, float d)
|
||||
{
|
||||
CheckTime(t, d);
|
||||
return c * t / d + b;
|
||||
}
|
||||
|
||||
public static float InQuad(float t) => NormalizedTime(InQuad, t);
|
||||
public static float InQuad(float time, float start, float end) => TimeRange(InQuad, time, start, end);
|
||||
|
||||
public static float InQuad(float t, float b, float c, float d)
|
||||
{
|
||||
CheckTime(t, d);
|
||||
t = t / d;
|
||||
return c * (t * t) + b;
|
||||
}
|
||||
|
||||
public static float OutQuad(float t) => NormalizedTime(OutQuad, t);
|
||||
public static float OutQuad(float time, float start, float end) => TimeRange(OutQuad, time, start, end);
|
||||
|
||||
public static float OutQuad(float t, float b, float c, float d)
|
||||
{
|
||||
CheckTime(t, d);
|
||||
t = t / d;
|
||||
return -c * t * (t - 2) + b;
|
||||
}
|
||||
|
||||
public static float InOutQuad(float t) => NormalizedTime(InOutQuad, t);
|
||||
public static float InOutQuad(float time, float start, float end) => TimeRange(InOutQuad, time, start, end);
|
||||
|
||||
public static float InOutQuad(float t, float b, float c, float d)
|
||||
{
|
||||
CheckTime(t, d);
|
||||
t = t / d * 2;
|
||||
if (t < 1)
|
||||
{
|
||||
return c / 2 * (t * t) + b;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -c / 2 * ((t - 1) * (t - 3) - 1) + b;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26124.0
|
||||
MinimumVisualStudioVersion = 15.0.26124.0
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Easing", "Easing\Easing.csproj", "{3227364C-6091-429B-B460-E9AA410BC1C0}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{F9F67512-233D-4C1A-A756-23FC8B1E92CA}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{3227364C-6091-429B-B460-E9AA410BC1C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3227364C-6091-429B-B460-E9AA410BC1C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3227364C-6091-429B-B460-E9AA410BC1C0}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{3227364C-6091-429B-B460-E9AA410BC1C0}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{3227364C-6091-429B-B460-E9AA410BC1C0}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{3227364C-6091-429B-B460-E9AA410BC1C0}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{3227364C-6091-429B-B460-E9AA410BC1C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3227364C-6091-429B-B460-E9AA410BC1C0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3227364C-6091-429B-B460-E9AA410BC1C0}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{3227364C-6091-429B-B460-E9AA410BC1C0}.Release|x64.Build.0 = Release|Any CPU
|
||||
{3227364C-6091-429B-B460-E9AA410BC1C0}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{3227364C-6091-429B-B460-E9AA410BC1C0}.Release|x86.Build.0 = Release|Any CPU
|
||||
{F9F67512-233D-4C1A-A756-23FC8B1E92CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F9F67512-233D-4C1A-A756-23FC8B1E92CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F9F67512-233D-4C1A-A756-23FC8B1E92CA}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{F9F67512-233D-4C1A-A756-23FC8B1E92CA}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{F9F67512-233D-4C1A-A756-23FC8B1E92CA}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{F9F67512-233D-4C1A-A756-23FC8B1E92CA}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{F9F67512-233D-4C1A-A756-23FC8B1E92CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F9F67512-233D-4C1A-A756-23FC8B1E92CA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F9F67512-233D-4C1A-A756-23FC8B1E92CA}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{F9F67512-233D-4C1A-A756-23FC8B1E92CA}.Release|x64.Build.0 = Release|Any CPU
|
||||
{F9F67512-233D-4C1A-A756-23FC8B1E92CA}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{F9F67512-233D-4C1A-A756-23FC8B1E92CA}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,83 @@
|
|||
using NUnit.Framework;
|
||||
using FluentAssertions;
|
||||
|
||||
using MoonTools.Core.Easing;
|
||||
using System;
|
||||
|
||||
namespace Test
|
||||
{
|
||||
public class EasingTests
|
||||
{
|
||||
[Test]
|
||||
public void Linear()
|
||||
{
|
||||
Easing.Linear(0.25f).Should().Be(0.25f);
|
||||
Easing.Linear(0.5f).Should().Be(0.5f);
|
||||
Easing.Linear(0.75f).Should().Be(0.75f);
|
||||
|
||||
Action invalidTime = () => Easing.Linear(1.5f);
|
||||
invalidTime.Should().Throw<ArgumentException>();
|
||||
|
||||
Easing.Linear(3, 2, 6).Should().Be(3f);
|
||||
Easing.Linear(4, 2, 6).Should().Be(4f);
|
||||
Easing.Linear(5, 2, 6).Should().Be(5f);
|
||||
|
||||
invalidTime = () => Easing.Linear(7, 2, 6);
|
||||
invalidTime.Should().Throw<ArgumentException>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InQuad()
|
||||
{
|
||||
Easing.InQuad(0.25f).Should().Be(0.0625f);
|
||||
Easing.InQuad(0.5f).Should().Be(0.25f);
|
||||
Easing.InQuad(0.75f).Should().Be(0.5625f);
|
||||
|
||||
Action invalidTime = () => Easing.InQuad(1.5f);
|
||||
invalidTime.Should().Throw<ArgumentException>();
|
||||
|
||||
Easing.InQuad(3, 2, 6).Should().Be(2.25f);
|
||||
Easing.InQuad(4, 2, 6).Should().Be(3f);
|
||||
Easing.InQuad(5, 2, 6).Should().Be(4.25f);
|
||||
|
||||
invalidTime = () => Easing.InQuad(7, 2, 6);
|
||||
invalidTime.Should().Throw<ArgumentException>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OutQuad()
|
||||
{
|
||||
Easing.OutQuad(0.25f).Should().Be(0.4375f);
|
||||
Easing.OutQuad(0.5f).Should().Be(0.75f);
|
||||
Easing.OutQuad(0.75f).Should().Be(0.9375f);
|
||||
|
||||
Action invalidTime = () => Easing.OutQuad(1.5f);
|
||||
invalidTime.Should().Throw<ArgumentException>();
|
||||
|
||||
Easing.OutQuad(3, 2, 6).Should().Be(3.75f);
|
||||
Easing.OutQuad(4, 2, 6).Should().Be(5f);
|
||||
Easing.OutQuad(5, 2, 6).Should().Be(5.75f);
|
||||
|
||||
invalidTime = () => Easing.OutQuad(7, 2, 6);
|
||||
invalidTime.Should().Throw<ArgumentException>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InOutQuad()
|
||||
{
|
||||
Easing.InOutQuad(0.25f).Should().Be(0.125f);
|
||||
Easing.InOutQuad(0.5f).Should().Be(0.5f);
|
||||
Easing.InOutQuad(0.75f).Should().Be(0.875f);
|
||||
|
||||
Action invalidTime = () => Easing.InOutQuad(1.5f);
|
||||
invalidTime.Should().Throw<ArgumentException>();
|
||||
|
||||
Easing.InOutQuad(3, 2, 6).Should().Be(2.5f);
|
||||
Easing.InOutQuad(4, 2, 6).Should().Be(4f);
|
||||
Easing.InOutQuad(5, 2, 6).Should().Be(5.5f);
|
||||
|
||||
invalidTime = () => Easing.InOutQuad(7, 2, 6);
|
||||
invalidTime.Should().Throw<ArgumentException>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="nunit" Version="3.12.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
|
||||
<PackageReference Include="FluentAssertions" Version="5.9.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Easing\Easing.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
Reference in New Issue