function fadeToNewColor() {
    "use strict";
    if (newColor.isSame(oldColor)) {
        newColor.randomize(); //set the next new color before exit
        return;
    } else {
        var i; // used for iteration

        if (oldColor.r !== newColor.r) {
            oldColor.r = oldColor.r < newColor.r ? oldColor.r += 1 : oldColor.r -= 1;
        }
        if (oldColor.g !== newColor.g) {
            oldColor.g = oldColor.g < newColor.g ? oldColor.g += 1 : oldColor.g -= 1;
        }
        if (oldColor.b !== newColor.b) {
            oldColor.b = oldColor.b < newColor.b ? oldColor.b += 1 : oldColor.b -= 1;
        }

        //Update the background and text based on the new increment
        body.style.backgroundColor = oldColor.toString();
        colorArray.innerHTML = "rgb[" + oldColor.toArray() + "]";
        for (i = 0; i < colorChg.length; i += 1) {
            colorChg[i].style.color = oldColor.inverseToString();
            colorChg[i].style.borderLeftColor = oldColor.inverseToString();
        }

        //Recursive call to this function set inside a setTimeout
        setTimeout(fadeToNewColor, 30);
    }
}
//Function used to fade the background to a new color
Function used to fade the background to a new color
Function used to fade the background to a new color
function fadeToNewColor() {
    "use strict";
    if (newColor.isSame(oldColor)) {
        newColor.randomize(); 
        return;
    } else {
        var i; 
        if (oldColor.r !== newColor.r) {
            oldColor.r = oldColor.r < newColor.r ? oldColor.r += 1 : oldColor.r -= 1;
        }
        if (oldColor.g !== newColor.g) {
            oldColor.g = oldColor.g < newColor.g ? oldColor.g += 1 : oldColor.g -= 1;
        }
        if (oldColor.b !== newColor.b) {
            oldColor.b = oldColor.b < newColor.b ? oldColor.b += 1 : oldColor.b -= 1;
        }
        body.style.backgroundColor = oldColor.toString();
        colorArray.innerHTML = "rgb[" + oldColor.toArray() + "]";
        for (i = 0; i < colorChg.length; i += 1) {
            colorChg[i].style.color = oldColor.inverseToString();
            colorChg[i].style.borderLeftColor = oldColor.inverseToString();
        }
        setTimeout(fadeToNewColor, 30);
    }
}
function fadeToNewColor ( ) { "use strict" ; if ( newColor . isSame ( oldColor ) ) { newColor . randomize ( ) ; return ; } else { var i ; if ( oldColor . r !== newColor . r ) { oldColor . r = oldColor . r < newColor . r ? oldColor . r += 1 : oldColor . r -= 1 ; } if ( oldColor . g !== newColor . g ) { oldColor . g = oldColor . g < newColor . g ? oldColor . g += 1 : oldColor . g -= 1 ; } if ( oldColor . b !== newColor . b ) { oldColor . b = oldColor . b < newColor . b ? oldColor . b += 1 : oldColor . b -= 1 ; } body . style . backgroundColor = oldColor . toString ( ) ; colorArray . innerHTML = "rgb[" + oldColor . toArray ( ) + "]" ; for ( i = 0 ; i < colorChg . length ; i += 1 ) { colorChg [ i ] . style . color = oldColor . inverseToString ( ) ; colorChg [ i ] . style . borderLeftColor = oldColor . inverseToString ( ) ; } setTimeout ( fadeToNewColor , 30 ) ; } }
Function used to fade the background to a new color
Function used to fade the background to a new color
//set the next new color before exit // used for iteration //Update the background and text based on the new increment //Recursive call to this function set inside a setTimeout