Ejemplo n.º 1
0
 /// <summary>
 /// Component-wise clips this <see cref="RGB"/> to between min and max.
 /// </summary>
 /// <param name="min">The min color.</param>
 /// <param name="max">The max color.</param>
 /// <returns>The component-wise clipped color.</returns>
 public RGB Clip(RGB min, RGB max)
 {
     return new RGB(Util.Clip(R, min.R, max.R), Util.Clip(G, min.G, max.G), Util.Clip(B, min.B, max.B));
 }
Ejemplo n.º 2
0
 public static bool TryParse(string str, out RGB result)
 {
     result = default(RGB);
     str = str.Trim();
     if(str.Length < "(0,0,0)".Length || str[0] != '(' || str[str.Length - 1] != ')') return false;
     //remove ( and )
     str = str.Substring(1, str.Length - 2);
     string[] parts = str.Split(',');
     if(parts.Length != 3) return false;
     if(!byte.TryParse(parts[0], out result.R) ||
        !byte.TryParse(parts[1], out result.G) ||
        !byte.TryParse(parts[2], out result.B)) return false;
     return true;
 }
Ejemplo n.º 3
0
 public static string Serialize(RGB value)
 {
     return string.Format("({0},{1},{2})", value.R, value.G, value.B);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a new <see cref="ARGB"/>.
 /// </summary>
 /// <param name="a">The alpha component.</param>
 /// <param name="rgb">The color component.</param>
 public ARGB(byte a, RGB rgb)
     : this()
 {
     this.RGB = rgb;
     this.A = a;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Interpolates between the given colors using the given extended interpolation function.
 /// </summary>
 /// <param name="past">The past value.</param>
 /// <param name="bottom">The bottom value.</param>
 /// <param name="top">The top value.</param>
 /// <param name="future">The future value.</param>
 /// <param name="mu">The mu value.</param>
 /// <param name="func">The extended interpolation function to use.</param>
 /// <returns>The resulting color.</returns>
 public static RGB Interpolate(RGB past, RGB bottom, RGB top, RGB future, double mu, ExtendedInterpFunction func)
 {
     return new RGB(InterpByte(past.R, bottom.R, top.R, future.R, mu, func),
                    InterpByte(past.G, bottom.G, top.G, future.G, mu, func),
                    InterpByte(past.B, bottom.B, top.B, future.B, mu, func));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Interpolates between the given colors using the given interpolation function.
 /// </summary>
 /// <param name="bottom">The bottom value.</param>
 /// <param name="top">The top value.</param>
 /// <param name="mu">The mu value.</param>
 /// <param name="func">The interpolation function to use.</param>
 /// <returns>The resulting color.</returns>
 public static RGB Interpolate(RGB bottom, RGB top, double mu, InterpFunction func)
 {
     return new RGB(InterpByte(bottom.R, top.R, mu, func), InterpByte(bottom.G, top.G, mu, func), InterpByte(bottom.B, top.B, mu, func));
 }