summaryrefslogtreecommitdiff
path: root/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-06-03 10:15:45 +0800
committerchai <215380520@qq.com>2024-06-03 10:15:45 +0800
commitacea7b2e728787a0d83bbf83c8c1f042d2c32e7e (patch)
tree0bfec05c1ca2d71be2c337bcd110a0421f19318b /Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators
parent88febcb02bf127d961c6471d9e846c0e1315f5c3 (diff)
+ plugins project
Diffstat (limited to 'Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators')
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/ColorInterpolator.cs13
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/HueInterpolator.cs12
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/Interpolator.cs26
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/OpacityInterpolator.cs10
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/RotationInterpolator.cs10
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/ScaleInterpolator.cs12
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/VelocityInterpolator12
7 files changed, 95 insertions, 0 deletions
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/ColorInterpolator.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/ColorInterpolator.cs
new file mode 100644
index 0000000..f94c689
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/ColorInterpolator.cs
@@ -0,0 +1,13 @@
+namespace MonoGame.Extended.Particles.Modifiers.Interpolators
+{
+ /// <summary>
+ /// Defines a modifier which interpolates the color of a particle over the course of its lifetime.
+ /// </summary>
+ public sealed class ColorInterpolator : Interpolator<HslColor>
+ {
+ public override unsafe void Update(float amount, Particle* particle)
+ {
+ particle->Color = HslColor.Lerp(StartValue, EndValue, amount);
+ }
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/HueInterpolator.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/HueInterpolator.cs
new file mode 100644
index 0000000..8b58a8e
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/HueInterpolator.cs
@@ -0,0 +1,12 @@
+using MonoGame.Extended;
+
+namespace MonoGame.Extended.Particles.Modifiers.Interpolators
+{
+ public class HueInterpolator : Interpolator<float>
+ {
+ public override unsafe void Update(float amount, Particle* particle)
+ {
+ particle->Color = new HslColor((EndValue - StartValue) * amount + StartValue, particle->Color.S, particle->Color.L);
+ }
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/Interpolator.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/Interpolator.cs
new file mode 100644
index 0000000..0ec9866
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/Interpolator.cs
@@ -0,0 +1,26 @@
+namespace MonoGame.Extended.Particles.Modifiers.Interpolators
+{
+ public abstract class Interpolator
+ {
+ protected Interpolator()
+ {
+ Name = GetType().Name;
+ }
+
+ public string Name { get; set; }
+ public abstract unsafe void Update(float amount, Particle* particle);
+ }
+
+ public abstract class Interpolator<T> : Interpolator
+ {
+ /// <summary>
+ /// Gets or sets the intial value when the particles are created.
+ /// </summary>
+ public virtual T StartValue { get; set; }
+
+ /// <summary>
+ /// Gets or sets the final value when the particles are retired.
+ /// </summary>
+ public virtual T EndValue { get; set; }
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/OpacityInterpolator.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/OpacityInterpolator.cs
new file mode 100644
index 0000000..0a26fcd
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/OpacityInterpolator.cs
@@ -0,0 +1,10 @@
+namespace MonoGame.Extended.Particles.Modifiers.Interpolators
+{
+ public class OpacityInterpolator : Interpolator<float>
+ {
+ public override unsafe void Update(float amount, Particle* particle)
+ {
+ particle->Opacity = (EndValue - StartValue) * amount + StartValue;
+ }
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/RotationInterpolator.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/RotationInterpolator.cs
new file mode 100644
index 0000000..44a72de
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/RotationInterpolator.cs
@@ -0,0 +1,10 @@
+namespace MonoGame.Extended.Particles.Modifiers.Interpolators
+{
+ public class RotationInterpolator : Interpolator<float>
+ {
+ public override unsafe void Update(float amount, Particle* particle)
+ {
+ particle->Rotation = (EndValue - StartValue) * amount + StartValue;
+ }
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/ScaleInterpolator.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/ScaleInterpolator.cs
new file mode 100644
index 0000000..aff9244
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/ScaleInterpolator.cs
@@ -0,0 +1,12 @@
+using Microsoft.Xna.Framework;
+
+namespace MonoGame.Extended.Particles.Modifiers.Interpolators
+{
+ public class ScaleInterpolator : Interpolator<Vector2>
+ {
+ public override unsafe void Update(float amount, Particle* particle)
+ {
+ particle->Scale = (EndValue - StartValue) * amount + StartValue;
+ }
+ }
+} \ No newline at end of file
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/VelocityInterpolator b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/VelocityInterpolator
new file mode 100644
index 0000000..bad04b1
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Modifiers/Interpolators/VelocityInterpolator
@@ -0,0 +1,12 @@
+using Microsoft.Xna.Framework;
+
+namespace MonoGame.Extended.Particles.Modifiers.Interpolators
+{
+ public class VelocityInterpolator : Interpolator<Vector2>
+ {
+ public override unsafe void Update(float amount, Particle* particle)
+ {
+ particle->Velocity = (EndValue - StartValue) * amount + StartValue;
+ }
+ }
+}