Пример #1
0
		/// <summary>
		/// Checks if current color is not further from target color than c2.
		/// </summary>
		/// <returns><c>true</c> if each color component of current color is not further from target color than c2; otherwise, <c>false</c>.</returns>
		/// <param name="c2">Color to compare to.</param>
		/// <param name="target">Target color.</param>
		public bool IsCloserOrSameTo(RGB target, RGB c2) {
			Func<byte, byte, byte, bool> inBetween = (t, b1, b2) => Math.Max(b1, b2) >= t && t >= Math.Min(b1,b2);
			return (
				inBetween(r, target.r, c2.r) &&
				inBetween(g, target.g, c2.g) &&
				inBetween(b, target.b, c2.b));
		}
Пример #2
0
		public ActionParams(AllowedLedActions action, RGB colorFrom, RGB colorTo, int startTime, int duration, int delayAfter, int tickLength) {
			this.action = action;
			this.colorFrom = colorFrom;
			this.colorTo = colorTo;
			this.startTime = startTime;
			this.duration = duration;
			this.delayAfter = delayAfter;
			this.tickLength = tickLength;
		}
Пример #3
0
		public ActionParams(AllowedLedActions action, RGB colorFrom, RGB colorTo, int startTime, int duration, int delayAfter, int tickLength
			, int count = 1, float upPct = 0.5f, float maxColorPct = 0, float firstColorPct = 0.33f, float secondColorPct = 0.33f):
		this(action, colorFrom, colorTo, startTime, duration, delayAfter, tickLength)
		{
			this.count = count;
			this.upPct = upPct;
			this.maxColorPct = maxColorPct;
			this.firstColorPct = firstColorPct;
			this.secondColorPct = secondColorPct;
		}
Пример #4
0
		/// <summary>
		/// Returns new color which is closer to target color by certain percent (0% - current color, 100% - target color);
		/// </summary>
		/// <returns>New color.</returns>
		/// <param name="target">Target.</param>
		/// <param name="percent">Percent.</param>
		public RGB MoveCloserTo(RGB target, double percent) {
			if (percent > 1) {
				throw new ArgumentException("percent should not be higher than 1.0");
			}
			Func<byte, byte, double, byte> moveByteCloserTo = (b1, b2, pct) => (byte)(b1 + (b2 - b1) * pct);
			return new RGB (moveByteCloserTo(r, target.r, percent), moveByteCloserTo(g, target.g, percent), moveByteCloserTo(b, target.b, percent));
		}
Пример #5
0
		public bool Follows(RGB c2) {
			return r > c2.r && g > c2.g && b > c2.b;
		}
Пример #6
0
		public bool Precedes(RGB c2) {
			return r < c2.r && g < c2.g && b < c2.b;
		}
Пример #7
0
		public RGB Add (RGB c2) {
			Func<byte, byte, byte> addOrMax = (b1, b2) => (b1 + b2 > byte.MaxValue ? byte.MaxValue : (byte)(b1 + b2));
			return new RGB (addOrMax(r,c2.r), addOrMax(g, c2.g), addOrMax(b, c2.b));
		}
Пример #8
0
		/// <summary>
		/// Returns maximum absolute difference on any color component.
		/// </summary>
		/// <returns></returns>
		/// <param name="target">Target color.</param>
		public byte MaxDifference(RGB target)
		{
			return Math.Max(Math.Max((byte)Math.Abs (target.r - r), (byte)Math.Abs (target.g - g)), (byte)Math.Abs (target.b - b));
		}
Пример #9
0
		/// <summary>
		/// Returns absolute difference between colors on all color componens.
		/// </summary>
		/// <returns></returns>
		/// <param name="target">Target color.</param>
		public RGB AbsoluteDifference(RGB target) {
			return new RGB((byte)Math.Abs (target.r - r), (byte)Math.Abs (target.g - g), (byte)Math.Abs (target.b - b));
		}
Пример #10
0
		private static extern int GetActionOutput (uint action, out int size, out IntPtr data, RGB colorFrom, RGB colorTo, int startTime, int duration, int delayAfter, int tickLength, int count, float upPct, float maxColorPct, float firstColorPct, float secondColorPct);