Skip to content

Commit 0010e7f

Browse files
committed
fix regression, make sure to round color components when outputting
1 parent 0b3f8ef commit 0010e7f

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

lessc.inc.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,10 +1404,15 @@ function compileValue($value) {
14041404
// [2] - green component
14051405
// [3] - blue component
14061406
// [4] - optional alpha component
1407+
list(, $r, $g, $b) = $value;
1408+
$r = round($r);
1409+
$g = round($g);
1410+
$b = round($b);
1411+
14071412
if (count($value) == 5 && $value[4] != 1) { // rgba
1408-
return 'rgba('.$value[1].','.$value[2].','.$value[3].','.$value[4].')';
1413+
return 'rgba('.$r.','.$g.','.$b.','.$value[4].')';
14091414
}
1410-
return sprintf("#%02x%02x%02x", round($value[1]), round($value[2]), round($value[3]));
1415+
return sprintf("#%02x%02x%02x", $r, $g, $b);
14111416
case 'function':
14121417
// [1] - function name
14131418
// [2] - some array value representing arguments, either ['string', value] or ['list', ',', values[]]

tests/outputs/colors.css

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
body {
22
color:#996d33;
3-
color:rgba(153,108.8,51,0.3);
3+
color:rgba(153,109,51,0.3);
44
lighten:#ffffff;
55
lighten:#7c8df2;
6-
lighten:rgba(222.44285714286,139.91428571429,128.55714285714,0.5);
6+
lighten:rgba(222,140,129,0.5);
77
darken:#d6d6d6;
88
darken:#0d1e81;
9-
darken:rgba(18.38188976378,42.358267716535,184.61811023622,0.5);
9+
darken:rgba(18,42,185,0.5);
1010
saturate:#f1eded;
1111
saturate:#0025fe;
12-
saturate:rgba(10.3,43.963461538462,243.7,0.5);
12+
saturate:rgba(10,44,244,0.5);
1313
desaturate:#efefef;
1414
desaturate:#3349cb;
15-
desaturate:rgba(35.7,62.036538461538,218.3,0.5);
15+
desaturate:rgba(36,62,218,0.5);
1616
spin:#efefef;
1717
spin:#2d17e7;
18-
spin:rgba(58.866666666667,23,231,0.5);
18+
spin:rgba(59,23,231,0.5);
1919
spin:#efefef;
2020
spin:#1769e7;
21-
spin:rgba(23,118.86666666667,231,0.5);
21+
spin:rgba(23,119,231,0.5);
2222
one:#abcdef;
2323
one:#abcdef;
2424
two:rgba(2,159,35,0.9);

0 commit comments

Comments
 (0)