Sha256: eca087e1d80317c55ab3fbabacf6d0b046d6e5844efb8ac1e04740e491bb4e9c

Contents?: true

Size: 639 Bytes

Versions: 2

Compression:

Stored size: 639 Bytes

Contents

ONECOLOR.installMethod('mix', function (otherColor, weight) {
    otherColor = ONECOLOR(otherColor).rgb();
    weight = 1 - (isNaN(weight) ? 0.5 : weight);

    var w = weight * 2 - 1,
        a = this._alpha - otherColor._alpha,
        weight1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2,
        weight2 = 1 - weight1,
        rgb = this.rgb();

    return new ONECOLOR.RGB(
        rgb._red * weight1 + otherColor._red * weight2,
        rgb._green * weight1 + otherColor._green * weight2,
        rgb._blue * weight1 + otherColor._blue * weight2,
        rgb._alpha * weight + otherColor._alpha * (1 - weight)
    );
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pleeease-0.0.3 node_modules/pleeease/node_modules/csswring/node_modules/onecolor/lib/color/plugins/mix.js
pleeease-0.0.2 node_modules/pleeease/node_modules/csswring/node_modules/onecolor/lib/color/plugins/mix.js