JSFiddle - React, Tailwind, and code Playground

by omni5cience

JavaScript

function Interpolate(start, end, step) {

}

function Color(red, green, blue, alpha) {
    this.red = red;
    this.green = green;
    this.blue = blue;
    this.alpha = alpha;
}

Color.prototype.toRGBA = function toRGBA() {
    var rgba = "rgba("+this.red+","+this.green+","+this.blue+","+this.alpha+")";
    console.log(rgba);
    return rgba;
};

var x = new Color(255, 127, 127, 1);
document.body.style.backgroundColor = x.toRGBA();


var current = 0,
    end = 255;

function interpolate() {
    if (current > end) {
        current = 0;
    }

    return current++;
}

function interpolateColor() {
    document.body.style.backgroundColor = "rgba(" + interpolate() + ",0,0,1)";
}

//window.x = setInterval(interpolateColor, 15);