1
0
Fork 0
forked from 0x2620/oxjs

less obscure Ox.map

This commit is contained in:
rolux 2012-05-22 16:29:37 +02:00
commit 12cf77cef5
21 changed files with 125 additions and 101 deletions

View file

@ -147,7 +147,7 @@ Ox.load.Image = function(options, callback) {
val = Ox.hsl([rgba[0], rgba[1], rgba[2]])[i];
rgb = i == 0
? Ox.rgb([val, 1, 0.5])
: Ox.map(Ox.range(3), function(v) {
: Ox.range(3).map(function() {
return parseInt(val * 255);
});
return Ox.merge(rgb, rgba[3]);
@ -343,9 +343,9 @@ Ox.load.Image = function(options, callback) {
: Ox.isNumber(arguments[2]) ? arguments[2] : 0,
b = 0, bin,
// Array of bits per byte to be modified (0 is LSB)
bits = mode < 1 ? [-mode] : Ox.map(Ox.range(8), function(bit) {
return mode & 1 << bit ? bit : null;
}),
bits = mode < 1 ? [-mode] : Ox.filter(Ox.range(8), function(i) {
return mode & 1 << i;
};
cap = getCapacity(bits.length), len;
// Compress the string
str = Ox[deflate ? 'encodeDeflate' : 'encodeUTF8'](str);
@ -359,7 +359,7 @@ Ox.load.Image = function(options, callback) {
str = str.substr(0, Math.ceil(cap));
// Create an array of bit values
bin = Ox.flatten(Ox.map(str, function(chr) {
return Ox.map(Ox.range(8), function(i) {
return Ox.range(8).map(function(i) {
return chr.charCodeAt(0) >> 7 - i & 1;
});
}));
@ -414,8 +414,8 @@ Ox.load.Image = function(options, callback) {
: Ox.isNumber(arguments[1]) ? arguments[1] : 0,
bin = '',
// Array of bits per byte to be modified (0 is LSB)
bits = mode < 1 ? [-mode] : Ox.map(Ox.range(8), function(b) {
return mode & 1 << b ? b : null;
bits = mode < 1 ? [-mode] : Ox.range(8).filter(function(i) {
return mode & 1 << i;
}),
done = 0, len = 4, str = '';
that.forEach(function(rgba, xy, index) {