mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Data binding modifiers - Finished color saturate/desaturate
Data binding modifiers - Added color invert Layer properties - Added FloatRange and IntRange layer properties
This commit is contained in:
1 parent
925bedc0a6
commit
0795069af2
15 files changed
+460
-9
No files matched your search
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a range between two single-precision floating point numbers
|
||||
/// </summary>
|
||||
public class FloatRange
|
||||
{
|
||||
private readonly Random _rand;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="FloatRange" /> class
|
||||
/// </summary>
|
||||
/// <param name="start">The start value of the range</param>
|
||||
/// <param name="end">The end value of the range</param>
|
||||
public FloatRange(float start, float end)
|
||||
{
|
||||
Start = start;
|
||||
End = end;
|
||||
|
||||
_rand = new Random();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the start value of the range
|
||||
/// </summary>
|
||||
public float Start { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the end value of the range
|
||||
/// </summary>
|
||||
public float End { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the given value is in this range
|
||||
/// </summary>
|
||||
/// <param name="value">The value to check</param>
|
||||
/// <param name="inclusive">
|
||||
/// Whether the value may be equal to <see cref="Start" /> or <see cref="End" />
|
||||
/// <para>Defaults to <see langword="true" /></para>
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
public bool IsInRange(float value, bool inclusive = true)
|
||||
{
|
||||
if (inclusive)
|
||||
return value >= Start && value <= End;
|
||||
return value > Start && value < End;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a pseudo-random value between <see cref="Start" /> and <see cref="End" />
|
||||
/// </summary>
|
||||
/// <param name="inclusive">Whether the value may be equal to <see cref="Start" /></param>
|
||||
/// <returns>The pseudo-random value</returns>
|
||||
public float GetRandomValue(bool inclusive = true)
|
||||
{
|
||||
if (inclusive)
|
||||
return _rand.Next((int) (Start * 100), (int) (End * 100)) / 100f;
|
||||
return _rand.Next((int) (Start * 100) + 1, (int) (End * 100)) / 100f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a range between two signed integers
|
||||
/// </summary>
|
||||
public class IntRange
|
||||
{
|
||||
private readonly Random _rand;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="IntRange" /> class
|
||||
/// </summary>
|
||||
/// <param name="start">The start value of the range</param>
|
||||
/// <param name="end">The end value of the range</param>
|
||||
public IntRange(int start, int end)
|
||||
{
|
||||
Start = start;
|
||||
End = end;
|
||||
|
||||
_rand = new Random();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the start value of the range
|
||||
/// </summary>
|
||||
public int Start { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the end value of the range
|
||||
/// </summary>
|
||||
public int End { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the given value is in this range
|
||||
/// </summary>
|
||||
/// <param name="value">The value to check</param>
|
||||
/// <param name="inclusive">
|
||||
/// Whether the value may be equal to <see cref="Start" /> or <see cref="End" />
|
||||
/// <para>Defaults to <see langword="true" /></para>
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
public bool IsInRange(int value, bool inclusive = true)
|
||||
{
|
||||
if (inclusive)
|
||||
return value >= Start && value <= End;
|
||||
return value > Start && value < End;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a pseudo-random value between <see cref="Start" /> and <see cref="End" />
|
||||
/// </summary>
|
||||
/// <param name="inclusive">Whether the value may be equal to <see cref="Start" /></param>
|
||||
/// <returns>The pseudo-random value</returns>
|
||||
public int GetRandomValue(bool inclusive = true)
|
||||
{
|
||||
if (inclusive)
|
||||
return _rand.Next(Start, End + 1);
|
||||
return _rand.Next(Start + 1, End);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user