forked from 0x2620/oxjs
some fixes for filters and form elements
This commit is contained in:
parent
842d536dc8
commit
3f3edac8c7
9 changed files with 113 additions and 79 deletions
|
|
@ -102,16 +102,18 @@ Ox.load.Image = function(options, callback) {
|
|||
]);
|
||||
};
|
||||
|
||||
that.channel = function(c) {
|
||||
c = c.toLowerCase();
|
||||
that.channel = function(str) {
|
||||
str = str[0].toLowerCase();
|
||||
return that.map(function(rgba) {
|
||||
var i = ['r', 'g', 'b'].indexOf(c), rgb, val;
|
||||
var i = ['r', 'g', 'b', 'a'].indexOf(str), rgb, val;
|
||||
if (i > -1) {
|
||||
return Ox.map(rgba, function(v, c) {
|
||||
return c == i || c == 3 ? v : 0;
|
||||
return str == 'a'
|
||||
? (c < 3 ? rgba[3] : 255)
|
||||
: (c == i || c == 3 ? v : 0);
|
||||
});
|
||||
} else {
|
||||
i = ['h', 's', 'l'].indexOf(c);
|
||||
i = ['h', 's', 'l'].indexOf(str);
|
||||
val = Ox.hsl([rgba[0], rgba[1], rgba[2]])[i];
|
||||
rgb = i == 0
|
||||
? Ox.rgb([val, 1, 0.5])
|
||||
|
|
@ -246,11 +248,15 @@ Ox.load.Image = function(options, callback) {
|
|||
Ox.forEach(bits, function(bit) {
|
||||
if ((
|
||||
mode < 1
|
||||
// If the number of bits set to 1, mod 2
|
||||
? Ox.sum(Ox.range(8).map(function(bit) {
|
||||
return self.data[i] & 1 << bit;
|
||||
})) % 2
|
||||
// or the one bit in question
|
||||
: self.data[i] & 1 << bit
|
||||
// is not equal to the data bit
|
||||
) != bin[b++]) {
|
||||
// then flip the bit
|
||||
self.data[i] ^= 1 << bit;
|
||||
}
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue