Exemplo n.º 1
0
        /// <summary>
        /// Scales this color instances RGBA values by the given factors
        /// </summary>
        public static IColorObject Scale(this IColorObject color, double redFactor, double greenFactor, double blueFactor, double alphaFactor)
        {
            if (color is null)
            {
                throw new ArgumentNullException(nameof(color));
            }
            Contract.EndContractBlock();

            Vector4 scale = new Vector4((float)redFactor, (float)greenFactor, (float)blueFactor, (float)alphaFactor);

            color.SetVector(color.GetVector() * scale);
            return(color);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Scales this color instances RGBA values by the given factors
        /// </summary>
        public static IColorObject Scale(this IColorObject color, float redFactor, float greenFactor, float blueFactor, float alphaFactor)
        {
            if (color is null)
            {
                throw new ArgumentNullException(nameof(color));
            }
            Contract.EndContractBlock();

            Vector4 scale = new Vector4(redFactor, greenFactor, blueFactor, alphaFactor);

            color.SetVector(color.GetVector() * scale);
            return(color);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Linearly interpolates between this color and another using the given <paramref name="blendFactor"/>.
        /// </summary>
        /// <param name="right">The color to interpolate toward</param>
        /// <param name="blendFactor">[0-1] range factor for interpolation</param>
        public T Mix(IColorObject right, float blendFactor)
        {// Linear Interp:  (x * (1.0 - i) + y * i);
            if (right is null)
            {
                throw new ArgumentNullException(nameof(right));
            }
            //if (blendFactor < 0 || blendFactor > 1f) throw new ArgumentOutOfRangeException(nameof(blendFactor));// No need to constrain this, let them have freedom to abuse it
            Contract.EndContractBlock();

            var RetVal = (GetVector() * (1f - blendFactor)) + (right.GetVector() * blendFactor);

            RetVal *= fbyteMax;
            return(From(RetVal));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Scales this color instances alpha value by the given factor
        /// </summary>
        public static IColorObject ScaleAlpha(this IColorObject color, double alphaFactor)
        {
            if (color is null)
            {
                throw new ArgumentNullException(nameof(color));
            }
            Contract.EndContractBlock();

            var Scalar = color.GetVector();

            Scalar.W *= (float)alphaFactor;
            color.SetVector(Scalar);
            return(color);
        }
Exemplo n.º 5
0
 public T Multiply(ColorObject <T> left, IColorObject right)
 {
     return(left * right);
 }
Exemplo n.º 6
0
 public T Subtract(ColorObject <T> left, IColorObject right)
 {
     return(left - right);
 }
Exemplo n.º 7
0
 public T Add(ColorObject <T> left, IColorObject right)
 {
     return(left + right);
 }
Exemplo n.º 8
0
 public T Divide(ColorObject <T> left, IColorObject right)
 {
     return(left / right);
 }