fix Ox.formatColor()

This commit is contained in:
rlx 2011-09-17 14:02:17 +00:00
parent 73fb2e3229
commit d3d2829464

View file

@ -2405,7 +2405,7 @@ Ox.formatArea = function(num, dec) {
Ox.formatColor <f> (strange one)
@*/
Ox.formatColor = function(val, type) {
var background, color;
var background, color, element;
if (type == 'hue') {
background = Ox.rgb(val, 1, 0.25).map(function(val) {
return Math.round(val);
@ -2427,38 +2427,36 @@ Ox.formatColor = function(val, type) {
return Math.round(val * 255);
});
color = Ox.range(3).map(function() {
var v = val * 255;
var v = Math.round(val * 255);
return val < 0.5 ? 128 + v : 255 - v;
});
Ox.print('COLOR', color)
}
return Ox.element('<div>')
element = Ox.element('<div>')
.css({
borderRadius: '4px',
padding: '0 3px 1px 3px',
background: Ox.isNumber(background[0])
? 'rgb(' + background.join(', ') + ')'
: Ox.print([/*'moz', 'o', */'webkit'].map(function(browser) {
return '-' + browser + '-linear-gradient(left, '
+ background.map(function(rgb, i) {
return 'rgb(' + rgb.join(', ') + ') '
+ Math.round(i * 100 / 6) + '%';
}).join(', ')
+ ')';
}).join(', ')) &&
[/*'moz', 'o', */'webkit'].map(function(browser) {
return '-' + browser + '-linear-gradient(left, '
+ background.map(function(rgb, i) {
return 'rgb(' + rgb.join(', ') + ') '
+ Math.round(i * 100 / 6) + '%';
}).join(', ')
+ ')';
}).join(', '),
color: 'rgb(' + color.join(', ') + ')',
overflow: 'hidden',
textOverflow: 'ellipsis',
//textShadow: 'black 1px 1px 1px'
})
.html(Ox.formatNumber(val, 3));
if (Ox.isNumber(background[0])) {
element.css({background: 'rgb(' + background.join(', ') + ')'});
} else {
['moz', 'o', 'webkit'].forEach(function(browser) {
element.css({
background: '-' + browser + '-linear-gradient(left, '
+ background.map(function(rgb, i) {
return 'rgb(' + rgb.join(', ') + ') '
+ Math.round(i * 100 / 6) + '%';
}).join(', ')
+ ')'
});
});
}
return element
};
/*@