Skip to content

Commit

Permalink
Version 3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Brzek committed Jun 17, 2014
1 parent cf1ba0c commit 4c231e5
Show file tree
Hide file tree
Showing 7 changed files with 298 additions and 51 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ README.md file is automatically generated.
**[Documentation](#documentation) |**

---
### Current version: v3.0.1 (2014-05-27)
### Current version: v3.0.2 (2014-06-17)

## What's new?
* Compiling LESS Hat is much more faster (up to 60× times).
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lesshat",
"version": "3.0.1",
"version": "3.0.2",
"main": [
"./build/lesshat.less",
"./build/lesshat-prefixed.less"
Expand Down
10 changes: 5 additions & 5 deletions build/lesshat-prefixed.less

Large diffs are not rendered by default.

252 changes: 252 additions & 0 deletions build/lesshat.css

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions build/lesshat.less

Large diffs are not rendered by default.

71 changes: 33 additions & 38 deletions mixins/background-image/background-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ backgroundImage.ms = function backgroundImageMs(value) {
},
'-45deg': 'x1=\"0%\" y1=\"0%\" x2=\"100%\" y2=\"100%\"',
'45deg': 'x1=\"0%\" y1=\"100%\" x2=\"100%\" y2=\"0%\"',
'ellipse at center': 'cx=\"50%\" cy=\"50%\" r=\"75%\"'
'ellipse at center': 'cx=\"50%\" cy=\"50%\" r=\"75%\"',
get '135deg' () {
return this['-45deg'];
}
};
var svg = {
uri_data: 'url(data:image/svg+xml;base64,',
Expand Down Expand Up @@ -228,54 +231,46 @@ backgroundImage.ms = function backgroundImageMs(value) {
// Colors
var colors_count = gradient.match(/rgb|#[a-zA-Z0-9]|hsl/g).length;
obj.svg_stops = [];

// replace
gradient = gradient.replace(/transparent/g, 'rgba(0,0,0,0)');

// hex
if (gradient.match(/#[a-zA-Z0-9]/g) && (gradient.match(/#[a-zA-Z0-9]/g).length == colors_count)) {
// Are there percentages?
if (gradient.match((/#[a-zA-Z0-9]+\s+(\d+%)/g)) && gradient.match((/#[a-zA-Z0-9]+\s+(\d+%)/g)).length == colors_count) {
gradient.match(/#[a-zA-Z0-9]+\s+(\d+%)/g).forEach(function(inner_val) {
if (gradient.match(/#[a-zA-Z0-9]/g)) {
gradient.match(/(#[a-zA-Z0-9]+)\s*(\d+%)?/g).forEach(function(inner_val) {
inner_val = inner_val.split(' ');
obj.svg_stops.push('<stop offset=\"' + inner_val[1] + '\" stop-color=\"' + inner_val[0] + '\" stop-opacity=\"1\"/>');
});
} else {
var shares = Math.floor(100 / (gradient.match(/#[a-zA-Z0-9]/g).length - 1));
gradient.match(/#[a-zA-Z0-9]+/g).forEach(function(inner_val, index) {
obj.svg_stops.push('<stop offset=\"' + (shares * index) + '%\" stop-color=\"' + inner_val + '\" stop-opacity=\"1\"/>');
obj.svg_stops.push('<stop offset=\"' + (inner_val[1] || false) + '\" stop-color=\"' + inner_val[0] + '\" stop-opacity=\"1\"/>');
});
}
}
// Rgb(a)
if (gradient.match(/rgba?\(\d+,\s*\d+,\s*\d+(?:,\s*(0|1|\.\d+|0\.\d+))?\)/g) && (gradient.match(/(?:rgb|rgba)?\(\d+,\s*\d+,\s*\d+(?:,\s*(0|1|\.\d+|0\.\d+))?\)/g).length == colors_count)) {
// Are there percentages?
if (gradient.match(/rgba?\(\d+,\s*\d+,\s*\d+(?:,\s*(0|1|\.\d+|0\.\d+))?\)\s+\d+%+/g) && (gradient.match(/rgba?\(\d+,\s*\d+,\s*\d+(?:,\s*(0|1|\.\d+|0\.\d+))?\)\s+\d+%+/g).length) == colors_count) {
gradient.replace(/rgba?\((\d+,\s*\d+,\s*\d+)(?:,\s*(0|1|\.\d+|0\.\d+))?\)\s+(\d+%)+/g, function(match, sub, sub_2, sub_3) {
obj.svg_stops.push('<stop offset=\"' + sub_3 + '\" stop-color=\"rgb(' + sub + ')\" stop-opacity=\"' + (sub_2 || 1) + '\"/>');
});
} else {
var shares = Math.floor(100 / (gradient.match(/(rgb|rgba)\(/g).length - 1));
gradient.match(/rgba?\((\d+,\s*\d+,\s*\d+)(?:,\s*(0|1|\.\d+|0\.\d+))?\)/g).forEach(function(element, index) {
element.replace(/rgba?\((\d+,\s*\d+,\s*\d+)(?:,\s*(0|1|\.\d+|0\.\d+))?\)/g, function(match, sub, sub_2, sub_3) {
obj.svg_stops.push('<stop offset=\"' + (shares * index) + '%\" stop-color=\"rgb(' + sub + ')\" stop-opacity=\"' + (sub_2 || 1) + '\"/>');
});
if (gradient.match(/rgba?\(\d+,\s*\d+,\s*\d+(?:,\s*(0|1|\.\d+|0\.\d+))?\)/g)) {
gradient.replace(/rgba?\((\d+,\s*\d+,\s*\d+)(?:,\s*(0|1|\.\d+|0\.\d+))?\)\s*(\d+%)?/g, function(match, sub, sub_2, sub_3) {
obj.svg_stops.push('<stop offset=\"' + (sub_3 || false) + '\" stop-color=\"rgb(' + sub + ')\" stop-opacity=\"' + (sub_2 || 1) + '\"/>');
});
}
}
// Hsl(a)
if (gradient.match(/hsla?\((\d+,\s*\d+%,\s*\d+%),\s*(0|1|\.\d+|0\.\d+)\)/g) && (gradient.match(/hsla?\((\d+,\s*\d+%,\s*\d+%),\s*(0|1|\.\d+|0\.\d+)\)/g).length == colors_count)) {
// Are there percentages?
if (gradient.match(/hsla?\((\d+,\s*\d+%,\s*\d+%),\s*(0|1|\.\d+|0\.\d+)\)\s*(\d+%)+/g) && (gradient.match(/hsla?\((\d+,\s*\d+%,\s*\d+%),\s*(0|1|\.\d+|0\.\d+)\)\s*(\d+%)+/g).length) == colors_count) {
gradient.replace(/hsla?\((\d+,\s*\d+%,\s*\d+%),\s*(0|1|\.\d+|0\.\d+)\)\s*(\d+%)+/g, function(match, sub, sub_2, sub_3) {
obj.svg_stops.push('<stop offset=\"' + sub_3 + '\" stop-color=\"hsl(' + sub + ')\" stop-opacity=\"' + (sub_2 || 1) + '\"/>');
if (gradient.match(/hsla?\((\d+,\s*\d+%,\s*\d+%),\s*(0|1|\.\d+|0\.\d+)\)/g)) {
gradient.replace(/hsla?\((\d+,\s*\d+%,\s*\d+%),\s*(0|1|\.\d+|0\.\d+)\)\s*(\d+%)?/g, function(match, sub, sub_2, sub_3) {
obj.svg_stops.push('<stop offset=\"' + (sub_3 || false) + '\" stop-color=\"hsl(' + sub + ')\" stop-opacity=\"' + (sub_2 || 1) + '\"/>');
});
} else {
var shares = Math.floor(100 / (gradient.match(/(hsl|hsla)\(/g).length - 1));
gradient.match(/hsla?\((\d+,\s*\d+%,\s*\d+%),\s*(0|1|\.\d+|0\.\d+)\)/g).forEach(function(element, index) {
element.replace(/hsla?\((\d+,\s*\d+%,\s*\d+%),\s*(0|1|\.\d+|0\.\d+)\)/g, function(match, sub, sub_2, sub_3) {
obj.svg_stops.push('<stop offset=\"' + (shares * index) + '%\" stop-color=\"hsl(' + sub + ')\" stop-opacity=\"' + (sub_2 || 1) + '\"/>');
});
});
}
}

var shares = Math.floor(100 / (colors_count - 1));
obj.svg_stops.forEach(function(el, i) {
if (/offset="false"/.test(el)) {
obj.svg_stops[i] = el.replace(/offset="false"/, 'offset="' + (shares * i) + '%"');
}
});

obj.svg_stops.sort(function(a, b) {
a = a.match(/offset="(\d+)%"/);
b = b.match(/offset="(\d+)%"/);

if (a.length == 2 && b.length == 2) {
return a[1] - b[1];
}
});

// save to array
svg_gradients.push(obj);
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "lesshat",
"description": "Most advanced LESS CSS mixins library",
"version": "3.0.1",
"version": "3.0.2",
"homepage": "http://lesshat.com/",
"author": {
"name": "Petr Brzek",
Expand Down

0 comments on commit 4c231e5

Please sign in to comment.