Example #1
0
        public static float SmoothStep(float value1, float value2, float amount)
        {
            // It is expected that 0 < amount < 1
            // If amount < 0, return value1
            // If amount > 1, return value2
            float result = MathHelp.Clamp(amount, 0f, 1f);

            result = MathHelp.Hermite(value1, 0f, value2, 0f, result);

            return(result);
        }
Example #2
0
 public Color32(Color32 color, int alpha)
 {
     if ((alpha & 0xFFFFFF00) != 0)
     {
         var clampedA = (uint)MathHelp.Clamp(alpha, Byte.MinValue, Byte.MaxValue);
         _packedValue = (color._packedValue & 0x00FFFFFF) | (clampedA << 24);
     }
     else
     {
         _packedValue = (color._packedValue & 0x00FFFFFF) | ((uint)alpha << 24);
     }
 }
Example #3
0
        public Color32(int r, int g, int b, int alpha)
        {
            if (((r | g | b | alpha) & 0xFFFFFF00) != 0)
            {
                var clampedR = (uint)MathHelp.Clamp(r, Byte.MinValue, Byte.MaxValue);
                var clampedG = (uint)MathHelp.Clamp(g, Byte.MinValue, Byte.MaxValue);
                var clampedB = (uint)MathHelp.Clamp(b, Byte.MinValue, Byte.MaxValue);
                var clampedA = (uint)MathHelp.Clamp(alpha, Byte.MinValue, Byte.MaxValue);

                _packedValue = (clampedA << 24) | (clampedB << 16) | (clampedG << 8) | (clampedR);
            }
            else
            {
                _packedValue = ((uint)alpha << 24) | ((uint)b << 16) | ((uint)g << 8) | ((uint)r);
            }
        }
Example #4
0
        public Color32(int r, int g, int b)
        {
            _packedValue = 0xFF000000;

            if (((r | g | b) & 0xFFFFFF00) != 0)
            {
                var clampedR = (uint)MathHelp.Clamp(r, Byte.MinValue, Byte.MaxValue);
                var clampedG = (uint)MathHelp.Clamp(g, Byte.MinValue, Byte.MaxValue);
                var clampedB = (uint)MathHelp.Clamp(b, Byte.MinValue, Byte.MaxValue);

                _packedValue |= (clampedB << 16) | (clampedG << 8) | (clampedR);
            }
            else
            {
                _packedValue |= ((uint)b << 16) | ((uint)g << 8) | ((uint)r);
            }
        }