diff --git a/lib/less/functions.js b/lib/less/functions.js index 6e2e774f..6e039f8e 100644 --- a/lib/less/functions.js +++ b/lib/less/functions.js @@ -237,6 +237,18 @@ tree.functions = { }, _isa: function (n, Type) { return (n instanceof Type) ? tree.True : tree.False; + }, + + /* Blending modes */ + + softlight: function(color1, color2) { + var t = color2.rgb[0] * color1.rgb[0] / 255; + var r = t + color1.rgb[0] * (255 - (255 - color1.rgb[0]) * (255 - color2.rgb[0]) / 255 - t) / 255; + t = color2.rgb[1] * color1.rgb[1] / 255; + var g = t + color1.rgb[1] * (255 - (255 - color1.rgb[1]) * (255 - color2.rgb[1]) / 255 - t) / 255; + t = color2.rgb[2] * color1.rgb[2] / 255; + var b = t + color1.rgb[2] * (255 - (255 - color1.rgb[2]) * (255 - color2.rgb[2]) / 255 - t) / 255; + return this.rgb(r, g, b); } }; diff --git a/test/css/functions.css b/test/css/functions.css index 47731c27..b165f306 100644 --- a/test/css/functions.css +++ b/test/css/functions.css @@ -70,3 +70,6 @@ #alpha { alpha: rgba(153, 94, 51, 0.6); } +#blendmodes { + softlight: #ff0000; +} diff --git a/test/less/functions.less b/test/less/functions.less index 94ac71ef..f40c25dd 100644 --- a/test/less/functions.less +++ b/test/less/functions.less @@ -77,3 +77,7 @@ #alpha { alpha: darken(hsla(25, 50%, 50%, 0.6), 10%); } + +#blendmodes { + softlight: softlight(#f60000, #ffffff); +}